Help with SDL_Net SDLNet_TCP_Send() function

Hey everyone, I’m attempting to make a simple multiple client server using
the SDL_Net Library.

Currently, all goes smoothly until the SDLNet_TCP_Send() command.

At this point, the function returns 0. I know this is supposed to mean that
an error has occurred, but when I use SDLNet_GetError, the only thing it
returns is “Accept() failed”.

SendBuffer = new char[MessageStr.size()+1];

strcpy(SendBuffer,MessageStr.c_str());

int msgsize = strlen(SendBuffer)+1;

SendRet = SDLNet_TCP_Send(clients[clientno].CSock, (void *)SendBuffer,
msgsize);

if(SendRet == 0)

{

printf(“Network::Send() Error: %s”,SDLNet_GetError());

}

delete[] SendBuffer;

SendBuffer is defined elsewhere as a char*, and does contain the message it
should contain when I print it to the console. CSock is a TCPsocket, which
is assigned by using SDLNet_TCP_Accept().

I have no idea what’s causing this error - I’ve been through the connection
variables, all seem to be working correctly. The client remains connected
for the duration of the send.

If anyone has any ideas, I’d really appreciate the help!

Thanks!

Have you verified that SDLNet_TCP_Accept() didn’t error?On Thu, Jan 15, 2009 at 5:04 PM, Ben Ockmore wrote:

Hey everyone, I’m attempting to make a simple multiple client server using
the SDL_Net Library.

Currently, all goes smoothly until the SDLNet_TCP_Send() command.

At this point, the function returns 0. I know this is supposed to mean that
an error has occurred, but when I use SDLNet_GetError, the only thing it
returns is “Accept() failed”.

SendBuffer = new char[MessageStr.size()+1];

strcpy(SendBuffer,MessageStr.c_str());

int msgsize = strlen(SendBuffer)+1;

SendRet = SDLNet_TCP_Send(clients[clientno].CSock, (void *)SendBuffer,
msgsize);

if(SendRet == 0)

{

printf(“Network::Send() Error: %s”,SDLNet_GetError());

}

delete[] SendBuffer;

SendBuffer is defined elsewhere as a char*, and does contain the message it
should contain when I print it to the console. CSock is a TCPsocket, which
is assigned by using SDLNet_TCP_Accept().

I have no idea what’s causing this error ? I’ve been through the connection
variables, all seem to be working correctly. The client remains connected
for the duration of the send.

If anyone has any ideas, I’d really appreciate the help!

Thanks!


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


http://codebad.com/

Have you verified that SDLNet_TCP_Accept() didn’t error?

Yeah, that’s all I can see, other than being disappointed that the
SDL_SetError() that reported this accept() error didn’t put in the
output of strerror(errno)… :-(On Thu, Jan 15, 2009 at 5:58 PM, Donny Viszneki <donny.viszneki at gmail.com> wrote:


http://pphaneuf.livejournal.com/

SDL cannot change the behavior of strerror()

I suppose SDL could set errno, but there’s no compelling reason to do this.

You shouldn’t use errno or strerrno() to deal with SDL problems. Even
if you discover exceptional situations that you seem to be able to
handle using errno, SDL makes no guarantees of this being portable
between platforms nor different versions of SDL.On Thu, Jan 15, 2009 at 9:44 PM, Pierre Phaneuf wrote:

On Thu, Jan 15, 2009 at 5:58 PM, Donny Viszneki <@Donny_Viszneki> wrote:

Have you verified that SDLNet_TCP_Accept() didn’t error?

Yeah, that’s all I can see, other than being disappointed that the
SDL_SetError() that reported this accept() error didn’t put in the
output of strerror(errno)… :frowning:


http://pphaneuf.livejournal.com/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


http://codebad.com/

Oh I completely misunderstood what you said. Sorry!On Thu, Jan 15, 2009 at 11:53 PM, Donny Viszneki <@Donny_Viszneki> wrote:

SDL cannot change the behavior of strerror()

I suppose SDL could set errno, but there’s no compelling reason to do this.

You shouldn’t use errno or strerrno() to deal with SDL problems. Even
if you discover exceptional situations that you seem to be able to
handle using errno, SDL makes no guarantees of this being portable
between platforms nor different versions of SDL.

On Thu, Jan 15, 2009 at 9:44 PM, Pierre Phaneuf wrote:

On Thu, Jan 15, 2009 at 5:58 PM, Donny Viszneki <@Donny_Viszneki> wrote:

Have you verified that SDLNet_TCP_Accept() didn’t error?

Yeah, that’s all I can see, other than being disappointed that the
SDL_SetError() that reported this accept() error didn’t put in the
output of strerror(errno)… :frowning:


http://pphaneuf.livejournal.com/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


http://codebad.com/


http://codebad.com/