[enet-cvs] CVS: enet unix.c,1.9,1.10 win32.c,1.8,1.9

Lee Salzman enet-discuss@lists.puremagic.com
Thu, 20 Mar 2003 11:06:33 -0700


Update of /home/enet/cvsroot/enet
In directory sferik:/tmp/cvs-serv21145

Modified Files:
	unix.c win32.c 
Log Message:
Fixed a small buglet, listen after bind, but not the other way around


Index: unix.c
===================================================================
RCS file: /home/enet/cvsroot/enet/unix.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- unix.c	2003/03/09 02:17:05	1.9
+++ unix.c	2003/03/20 18:06:30	1.10
@@ -153,11 +153,11 @@
     sin.sin_port = ENET_HOST_TO_NET_16 (address -> port);
     sin.sin_addr.s_addr = address -> host;
 
-    if ((type == ENET_SOCKET_TYPE_STREAM &&
-          listen (newSocket, SOMAXCONN) == -1) ||
-        bind (newSocket, 
+    if (bind (newSocket, 
               (struct sockaddr *) & sin,
-              sizeof (struct sockaddr_in)) == -1)
+              sizeof (struct sockaddr_in)) == -1 ||
+        (type == ENET_SOCKET_TYPE_STREAM &&
+          listen (newSocket, SOMAXCONN) == -1))
     {
        close (newSocket);
 

Index: win32.c
===================================================================
RCS file: /home/enet/cvsroot/enet/win32.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- win32.c	2003/03/09 02:17:05	1.8
+++ win32.c	2003/03/20 18:06:30	1.9
@@ -113,12 +113,12 @@
        sin.sin_addr.s_addr = INADDR_ANY;
     }
 
-    if ((type == ENET_SOCKET_TYPE_STREAM &&
-          address != NULL &&
-          listen (newSocket, SOMAXCONN) == SOCKET_ERROR) ||
-        bind (newSocket,    
+    if (bind (newSocket,    
               (struct sockaddr *) & sin,
-              sizeof (struct sockaddr_in)) == SOCKET_ERROR)
+              sizeof (struct sockaddr_in)) == SOCKET_ERROR ||
+        (type == ENET_SOCKET_TYPE_STREAM &&
+          address != NULL &&
+          listen (newSocket, SOMAXCONN) == SOCKET_ERROR))
     {
        closesocket (newSocket);