Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - larztheloser

Pages: [1]
1
Network / TCP sending random characters
« on: January 27, 2011, 05:29:22 am »
Hey,

I'm having a problem creating a simple SFML network app. My client code looks like this:

Code: [Select]
... (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]

Pages: [1]