[Plib-cvs] plib/src/net netChannel.cxx,1.8,1.9 netSocket.cxx,1.27,1.28 netSocket.h,1.18,1.19
Brought to you by:
sjbaker
From: Steve B. <sj...@us...> - 2004-03-22 19:55:10
|
Update of /cvsroot/plib/plib/src/net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5846/plib/src/net Modified Files: netChannel.cxx netSocket.cxx netSocket.h Log Message: Fixed some odd network library issues. Index: netChannel.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/net/netChannel.cxx,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- netChannel.cxx 21 Mar 2004 17:41:07 -0000 1.8 +++ netChannel.cxx 22 Mar 2004 19:44:50 -0000 1.9 @@ -48,8 +48,9 @@ close(); netChannel* prev = NULL ; + for ( netChannel* ch = channels; ch != NULL; - ch = ch -> next_channel ) + ch = ch -> next_channel ) { if (ch == this) { @@ -275,3 +276,4 @@ { while ( poll (timeout) ) ; } + Index: netSocket.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/net/netSocket.cxx,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- netSocket.cxx 21 Mar 2004 17:41:07 -0000 1.27 +++ netSocket.cxx 22 Mar 2004 19:44:50 -0000 1.28 @@ -64,7 +64,7 @@ void netAddress::set ( const char* host, int port ) { - memset(this, 0, sizeof(netAddress)); + memset(this, 0, sizeof(netAddress)); sin_family = AF_INET ; sin_port = htons (port); @@ -74,12 +74,11 @@ ** to do the work; the names "" and "<broadcast>" are special. */ - if (host[0] == '\0') { - sin_addr = INADDR_ANY; - } - if (host[0] == '<' && strcmp(host, "<broadcast>") == 0) { - sin_addr = INADDR_BROADCAST; - } + if (host[0] == '\0') + sin_addr = INADDR_ANY; + + if (host[0] == '<' && strcmp(host, "<broadcast>") == 0) + sin_addr = INADDR_BROADCAST; else { #if 0 @@ -144,16 +143,20 @@ memset(buf, 0, sizeof(buf)); gethostname(buf, sizeof(buf)-1); const hostent *hp = gethostbyname(buf); - if (hp && *hp->h_addr_list) + + if (hp && *hp->h_addr_list) { - in_addr addr = *((in_addr*)*hp->h_addr_list); + in_addr addr = *((in_addr*)*hp->h_addr_list); const char* host = inet_ntoa(addr); + if ( host ) return host ; - } + } + return "127.0.0.1" ; } + bool netAddress::getBroadcast () const { return sin_addr == INADDR_BROADCAST; } Index: netSocket.h =================================================================== RCS file: /cvsroot/plib/plib/src/net/netSocket.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- netSocket.h 21 Mar 2004 17:41:07 -0000 1.18 +++ netSocket.h 22 Mar 2004 19:44:50 -0000 1.19 @@ -89,9 +89,9 @@ int listen ( int backlog ) ; int accept ( netAddress* addr ) ; int connect ( const char* host, int port ) ; - int send ( const void * buffer, int size, int flags = 0 ) ; + int send ( const void * buffer, int size, int flags = 0 ) ; int sendto ( const void * buffer, int size, int flags, const netAddress* to ) ; - int recv ( void * buffer, int size, int flags = 0 ) ; + int recv ( void * buffer, int size, int flags = 0 ) ; int recvfrom ( void * buffer, int size, int flags, netAddress* from ) ; void setBlocking ( bool blocking ) ; @@ -111,3 +111,4 @@ #endif // NET_SOCKET_H + |