[SDL] SDLNet_TCP_Recv() returns... null socket?

L-28C kixdemp at gmail.com
Fri Sep 7 19:55:20 PDT 2007


Hello everyone!

Take a look:

-------------------------
// Receive player's name
result = SDLNet_TCP_Recv(me->Socket, me->Name, 16);
if (result < 0)
{
	fprintf(stderr, "Couldn't receive player's name: %s.\r\nClosing 
connection", SDLNet_GetError());
	SDLNet_TCP_Close(me->Socket);
	return -1;
}
-------------------------

I used GDB to find out that, before that snippet, me->Socket is valid, 
but after it's null. I know I close the socket if result is less than 0, 
but if the closing function executes then it must return -1 also, which 
means the next part of that function shouldn't execute...

This is in a different thread, but nothing happens on the other (main) 
thread, it just sits and waits for someone to connect, so that can't be 
affecting the output of this thread function.

Any reason why Recv() should null my socket?

Thanks!



More information about the SDL mailing list