I got this odd error where if I send some data from a client to a server the message is received but I also get a number of empty messages, the same amount as the nr of letters in the message (in the example below, the string "Hello" gets 5 empty messages.
It's a non-blocking system, the client sends simply using send() and the server's recieve-part looks like this:
Code:
case FD_READ:
{
CHAR Char;
INT Result;
std::string String;
std::vector<CHAR> Buffer;
while(TRUE)
{
Result = recv(W, &Char, 1, 0);
if(Result == SOCKET_ERROR)
{
if(WSAGetLastError() == WSAEWOULDBLOCK) break;
ErrorMessage = "recv() failed!";
return FALSE;
}
if(Result < 1) break;
Buffer.push_back(Char);
}
Buffer.push_back('\0');
String = "MSG: ";
String += &Buffer[0];
AddMessage(String);
return TRUE;
}
As an example, if the client sends the string "Hello" to the server it would receive these messages:
Code:
MSG: Hello
MSG:
MSG:
MSG:
MSG:
MSG:
Prolly some stupid error, but I just can't find it...