• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Help with getting Otserv information with C#

zippoxer

Active Member
Joined
Mar 18, 2008
Messages
105
Reaction score
44
Location
Israel
I tried this code:
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:
I tried this code:
Code:
// Connecting...
TcpClient client = new TcpClient("[B]k44.hopto.org", 7171[/B]);
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));
Why you testing your f*cking shit on my own server?
 
Why you testing your f*cking shit on my own server?

LOL.
Why not? ;)
Why are you using a cloned version of Cipsoft's Tibia Server illegally?
You too, make some inconvenience to someone else.

And by the way, I don't own anything called "f*cking shit", can you please clarify yourself again? ;)
 
Back
Top