( search forums )
Some tcp client help
Soldat Forums - Server Talk - Server Help
bja888
February 18, 2006, 5:02 am
Soldat Democracy, a server admin I am working on is having troubles. I can send and receive data but I cannot get it to log in. I don't know the language the original soldat admin was wrote in but I got a lot of it figured out. One thing I cannot figure out it what order the commands are sent in. Here is what I have right now...

[code]
client = new TcpClient();
client.Connect(connectTo, port32);
Byte[] data = new Byte[256];
String connectData = String.Empty;
String responseData = String.Empty;

// read for connection
stream = client.GetStream();
Int32 bytes = stream.Read(data, 0, data.Length);
connectData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);

MessageBox.Show(connectData); // this returns "Soldat Admin Connection Established..."
if(connectData.Substring(0,23) == "Soldat Admin Connection")
{
// insert password
data = System.Text.Encoding.ASCII.GetBytes(passWord);
stream.Write(data, 0, data.Length);

// read result
data = new Byte[256];
bytes = stream.Read(data, 0, data.Length);
responseData += System.Text.Encoding.ASCII.GetString(data, 0, bytes);

if(responseData.Substring(0,7) == "Invalid")
{
this.statusValue.Text = "Failed";
result = false;
connected = false;
}else{
this.statusValue.Text = "Connected";
result = true;
connected = true;
}
}else{
this.statusValue.Text = "Failed";
connected = false;
result = false;
}
MessageBox.Show(responseData); // this returns "Invalid server password. Cannot login"
[/code]
I know the password ip and ports are all valid. It has to be something with the order or methods used.

Deleted User
February 18, 2006, 7:27 am
Silly boy, you need to add "0x0D 0x0A" to the end of each packet you send... You need to use chr(13) & chr(10) / "\r\n" / "\0x0D\0x0A" / vbCrLf / NewLine - Depending on what the language you are using; uses.

Looks like your using the noobtacular .NET. Sigh.

bja888
February 18, 2006, 9:02 am
Ah yes... it makes since now. Every input string came with a break so it only makes since that the output would be in the same format. :)

I don't consider my self a hard core programmer so assembaly isn't my language or choice :) .NET works just fine!!

Deleted User
February 18, 2006, 9:19 am
Who said anything about ASM?
So adding the newline char's works now?

bja888
February 18, 2006, 9:05 pm
Yeppers! Now I need to figure out how to recieve the player list...

mar77a
February 18, 2006, 10:39 pm
bja, the admin source is available in the stickies of the developers corner forum.

bja888
February 18, 2006, 11:28 pm
I downloaded the source from the downloads on soldat.pl. The only problem is that I cannot read Delphi.
By then way... does anyone know the c# equivalent of a packed record?

Without using that source I wouldn't of gotten as far as I have.