I've written a little socket application in C# that checks for the current version of my program at every start, now in my test program for this everything works, i can send the string from the server and it will be properly shown on the client, but when I try to use an if statement with that string it just does not work. Example:
public void rcv(NetworkStream ns, TcpClient clientSocket)
{
on = false;
//sending some random string so the server will respond
Byte[] sendBytes = Encoding.ASCII.GetBytes("bla");
ns.Write(sendBytes, 0, sendBytes.Length);
//receiving server response
byte[] bytes = new byte[clientSocket.ReceiveBufferSize];
int bytesread = clientSocket.ReceiveBufferSize;
ns.Read(bytes, 0, bytesread);
//received response, now encoding it to a string from a byte array
string returndata =Encoding.ASCII.GetString(bytes);
ver = Convert.ToString(returndata);
//MessageBox.Show("ver\n" + ver);
//MessageBox.Show("return\n" + returndata);
on = true;
if (ver== "2.0.1")
{
MessageBox.Show("iahsd");
}
}
So as you can see, the test string im using that is being sent by the server is "2.0.1" does does display properly on a label, a message box and a textbox that i put in for testing. but the if branch at the end of the class does not accept it and skips over it, if i put an else statement in, it skips to that.
i have tried everything me and my friends could think of, tried changing the encoding, sent different strings, etc ..
full code of the client : http://pastebin.com/bQPghvAH