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.


Messages - larztheloser

Pages: [1]
1
Network / TCP sending random characters
« on: January 28, 2011, 05:56:43 am »
Just did some testing and Laurent's solution works better. Thanks though.

The biggest problem is still that it won't send more then one message (or maybe it wont receive more than one?)

2
Network / TCP sending random characters
« on: January 28, 2011, 05:11:25 am »
Quote
I had the same problem.


Mind sharing how you fixed it?

3
Network / TCP sending random characters
« on: January 28, 2011, 12:47:06 am »
Thanks, closing the string properly (duh!) solved most of the problem.

Quote
Instead, sometimes I cannot type anything at all


For some reason, adding the null terminating character changes this problem. It used to refuse to let me type anything. Now it inputs, but it won't send the message. I've noticed that both the client and the server can send a message only once. After that I can still type, but hitting the enter key has no effect. However, I know that the send function is still running because it correctly identifies when we have disconnected.

The server has also started to send an apparently blank message when it connects to the client.

Quote
At the moment everything in the buffer is being pronted out, even after the null-terminator at the end of the desired string


Seeing as I am re-creating the character array every time that Thread_Receive runs (presumably making the string blank), why should there be any characters after the null terminator?

4
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]