I tried this code:
It prints few empty lines instead of a XML code which contains the server information.
Can anyone help me?
Edit = The problem was the encoding of "info".
If it helps someone, the fixed code is:
You can lock this thread =]
Code:
// Connecting...
TcpClient client = new TcpClient("k44.hopto.org", 7171);
NetworkStream stream = client.GetStream();
// Sending the request:
stream.Write(new byte[] { 6, 0, 255, 255 }, 0, 4);
byte[] b = Encoding.ASCII.GetBytes("info");
stream.Write(b, 0, b.Length);
// Reading and printing the response:
byte[] b2 = new byte[1024];
int i = stream.Read(b2, 0, b2.Length);
Console.WriteLine(Encoding.UTF8.GetString(b2));
It prints few empty lines instead of a XML code which contains the server information.
Can anyone help me?
Edit = The problem was the encoding of "info".
If it helps someone, the fixed code is:
Code:
// Connecting...
TcpClient client = new TcpClient("k44.hopto.org", 7171);
NetworkStream stream = client.GetStream();
// Sending the request:
stream.Write(new byte[] { 6, 0, 255, 255 }, 0, 4);
[B]byte[] b = Encoding.UTF8.GetBytes("info");[/B]
stream.Write(b, 0, b.Length);
// Reading and printing the response:
byte[] b2 = new byte[1024];
int i = stream.Read(b2, 0, b2.Length);
Console.WriteLine(Encoding.UTF8.GetString(b2));
You can lock this thread =]
Last edited: