Hey,
I'm having a problem creating a simple SFML network app. My client code looks like this:
... (standard variables, includes, using sf namespace etc) ...
SocketTCP TCP;
string msg;
void Thread_Recieve(void* UserData)
{
char Buff[128];
size_t Received;
TCP.Receive(Buff, sizeof(Buff), Received);
cout << "Message from server: " << Buff << endl;
}
...(start of int main, open connection) ...
TCP.SetBlocking(false);
Thread reciever(&Thread_Recieve);
reciever.Launch();
while(true) {
msg="";
cin >> msg;
TCP.Send(msg.c_str(),msg.length());
if(msg=="QUIT") break;
}
TCP.Close();
...
My server code looks quite similar, obviously using a separate TCP for the client and so on.
What I expect this to do is, when I type something in either my client or my server window, it will come up exactly as I typed it on the other end.
Instead, sometimes I cannot type anything at all, and when I am able, it sends the string followed by a bunch of random characters (numbers, punctuation, letters, musical symbols etc).
Anyone have any idea why?[/code]