I am trying to communicate with my Minecraft server on the RCON port.
I have little clue how to use the sockets & streams stuff though.
Poking around, I found they all have something in common. Socket, InputStream & OutputStream.
I tried it in my code, but the return says nothing useful.
I know the code actually sends a packet out, because I get an acknowledgement from the server console [Rcon connection from: /1.2.3.4].
Its just the code I tried to assemble based on the interwebs returns something like [B@4053f750 from output. No idea what that is, nor can I search it in Google.
Can someone give a good site for explaining this stuff?
Thanks a bunch.
Socket s;
InputStream i;
DataInputStream iD;
OutputStream o;
DataOutputStream oD;
OnClickListener listenA=new OnClickListener(){
public void onClick(View v){
try{
s=new Socket("MyDomain.tld", 12345);
i=s.getInputStream();
iD=new DataInputStream(i);
o=s.getOutputStream();
oD=new DataOutputStream(o);
byte[] data=new byte[1024], packet={
(byte)0xFE, (byte)0xFD, // Magic bytes
(byte)0x09, // Challenge type
(byte)0xde, (byte)0xad, (byte)0xbe, (byte)0xef // Your ID token
};
o.write(packet);
i.read(data, 0, 1024);
guiMain.setTxt_Edit(encodeCArray(data.toString())); // returns a hex string to an edit box. I can then compare the packet to what I expect.
s.close();
}catch(UnknownHostException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}
}
};
Try instead: