[or-cvs] REUSEADDR on normal places means you can rebind to the port

Roger Dingledine arma at seul.org
Thu Mar 24 23:20:08 UTC 2005


Update of /home2/or/cvsroot/tor/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/tor/src/or

Modified Files:
	connection.c 
Log Message:
REUSEADDR on normal places means you can rebind to the port
right after somebody else has let it go. But REUSEADDR on win32
means to let you bind to the port _even when somebody else
already has it bound_. So, don't do that on Win32.


Index: connection.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.343
retrieving revision 1.344
diff -u -d -r1.343 -r1.344
--- connection.c	23 Mar 2005 23:19:18 -0000	1.343
+++ connection.c	24 Mar 2005 23:20:06 -0000	1.344
@@ -401,7 +401,9 @@
   uint16_t usePort;
   uint32_t addr;
   int s; /* the socket we're going to make */
+#ifndef MS_WINDOWS
   int one=1;
+#endif
 
   memset(&bindaddr,0,sizeof(struct sockaddr_in));
   if (parse_addr_port(bindaddress, NULL, &addr, &usePort)<0) {
@@ -425,7 +427,13 @@
     return -1;
   }
 
+#ifndef MS_WINDOWS
+  /* REUSEADDR on normal places means you can rebind to the port
+   * right after somebody else has let it go. But REUSEADDR on win32
+   * means to let you bind to the port _even when somebody else
+   * already has it bound_. So, don't do that on Win32. */
   setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void*) &one, sizeof(one));
+#endif
 
   if (bind(s,(struct sockaddr *)&bindaddr,sizeof(bindaddr)) < 0) {
     log_fn(LOG_WARN,"Could not bind to port %u: %s",usePort,



More information about the tor-commits mailing list