[gnet-dev] Patch for win32 socket accept



This patch against gnet HEAD lets me get the addresses of incoming
connections on win32. There might be a good reason why the socklen args
to accept() were NULL in the first place - but I can't see one.

-- 
Hans Petter
? gnet-win32-accept-addr.patch
Index: tcp.c
===================================================================
RCS file: /cvs/gnome/gnet/src/tcp.c,v
retrieving revision 1.59
diff -u -p -r1.59 tcp.c
--- tcp.c	7 Jun 2003 21:15:25 -0000	1.59
+++ tcp.c	11 Jun 2003 03:08:32 -0000
@@ -1113,6 +1113,7 @@ gnet_tcp_socket_server_accept (GTcpSocke
 {
   gint sockfd;
   struct sockaddr_storage sa;
+  socklen_t n;
   fd_set fdset;
   GTcpSocket* s;
 
@@ -1131,7 +1132,8 @@ gnet_tcp_socket_server_accept (GTcpSocke
 
   /* Don't force the socket into blocking mode */
 
-  sockfd = accept(socket->sockfd, (struct sockaddr*) &sa, NULL);
+  n = sizeof (sa);
+  sockfd = accept(socket->sockfd, (struct sockaddr*) &sa, &n);
   /* if it fails, looping isn't going to help */
 
   if (sockfd == INVALID_SOCKET)
@@ -1153,7 +1155,7 @@ gnet_tcp_socket_server_accept_nonblock (
 {
   gint sockfd;
   struct sockaddr_storage sa;
-
+  socklen_t n;
   fd_set fdset;
   GTcpSocket* s;
   u_long arg;
@@ -1176,7 +1178,8 @@ gnet_tcp_socket_server_accept_nonblock (
   if(ioctlsocket(socket->sockfd, FIONBIO, &arg))
     return NULL;
 
-  sockfd = accept(socket->sockfd, (struct sockaddr*) &sa, NULL);
+  n = sizeof (sa);
+  sockfd = accept(socket->sockfd, (struct sockaddr*) &sa, &n);
   /* if it fails, looping isn't going to help */
 
   if (sockfd == INVALID_SOCKET)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]