//Copyright (C) 2007 Ryan Houdek // //This library is free software; you can redistribute it and/or //modify it under the terms of the GNU Lesser General Public //License as published by the Free Software Foundation; either //version 2.1 of the License, or (at your option) any later version. // //This library is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU //Lesser General Public License for more details. // //You should have received a copy of the GNU Lesser General Public //License along with this library; if not, write to the Free Software //Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #ifndef tcputil_h #define tcputil_h 1 // receive a buffer from a TCP socket with error checking // this function handles the memory, so it can't use any [] arrays // returns 0 on any errors, or a valid char* on success char *getMsg(TCPsocket sock, char **buf) { Uint32 len,result; static char *_buf; // allow for a NULL buf, use a static internal one... if(!buf) buf=&_buf; // free the old buffer if(*buf) free(*buf); *buf=NULL; // receive the length of the string message result=SDLNet_TCP_Recv(sock,&len,sizeof(len)); if(result