00001 #ifdef HAVE_SDL_NET 00002 00003 #ifndef TCP_UTIL_H 00004 #define TCP_UTIL_H 00005 00006 #include "../constants.h" 00007 00008 class TCPUtil { 00009 00010 public: 00011 // receive a buffer from a TCP socket with error checking 00012 // this function handles the memory, so it can't use any [] arrays 00013 // returns 0 on any errors, or a valid char* on success 00014 // 00015 // if length==NULL, then no length is returned. (Assumes buf is a 0-terminated string) 00016 static char *receive(TCPsocket sock, char **buf, int *length=NULL); 00017 00018 // send a string buffer over a TCP socket with error checking 00019 // returns 0 on any errors, length sent on success 00020 // 00021 // if length==0, buf is assumed to be a 0 terminated string 00022 static int send(TCPsocket sock, char *buf, int length=0); 00023 }; 00024 00025 #endif 00026 00027 #endif
1.4.0