SDL_Net: typos in demo code

I’m looking over the demo code for SDL_Net, so far two issues:

the source for tcpmulticlient.cpp is not included in the zip file available
at http://jcatki.no-ip.org:8080/SDL_net/
(the demo code doesn’t seem to be at libsdl.org)

in tcputils.hpp, putMsg has a defect in its return value if buf is null or
the string is zero length (bold added):

// send a string buffer over a TCP socket with error checking
// returns 0 on any errors, length returned on success
int putMsg( TCPsocket sock, char *buf )
{
Uint32 len, result;

if(!buf || !strlen(buf))
  *  return(1);

…*

Cheers,
-Jason


Jason Harrison, PhD
Software Development
Human-Computer Interaction
Project Management

Cell: 604 644 8611
Email: @Jason_Harrison

Thanks to Yggy King for bringing this quote to my attention:
Thinking the world should entertain you leads to boredom and sloth. Thinking
you should entertain the world leads to bright clothes, odd graffiti and
amazing grace in running for the bus. – Ann Herbert

Wouldn’t it be better to return the actual length (which could be zero), and
return -1 on error?

JeffOn Thu October 30 2008 14:47, Jason Harrison wrote:

I’m looking over the demo code for SDL_Net, so far two issues:

the source for tcpmulticlient.cpp is not included in the zip file available
at http://jcatki.no-ip.org:8080/SDL_net/
(the demo code doesn’t seem to be at libsdl.org)

in tcputils.hpp, putMsg has a defect in its return value if buf is null or
the string is zero length (bold added):

// send a string buffer over a TCP socket with error checking
// returns 0 on any errors, length returned on success
int putMsg( TCPsocket sock, char *buf )
{
Uint32 len, result;

if(!buf || !strlen(buf))
  *  return(1);


*

Cheers,
-Jason