From 67c207d3526ffd2b2c69741b2ccf474c9af5382b Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Wed, 8 Nov 2000 03:57:03 +0000 Subject: [PATCH] fixed SO_REUSEADDR WIN32 strangeness --- src/cas/io/bsdSocket/casIntfIO.cc | 14 ++++++-------- src/rsrv/caservertask.c | 9 ++++++++- src/util/iocLogServer.c | 12 +++++++++++- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/cas/io/bsdSocket/casIntfIO.cc b/src/cas/io/bsdSocket/casIntfIO.cc index dac1e52ee..62417fc93 100644 --- a/src/cas/io/bsdSocket/casIntfIO.cc +++ b/src/cas/io/bsdSocket/casIntfIO.cc @@ -40,16 +40,14 @@ casIntfIO::casIntfIO (const caNetAddr &addrIn) : throw S_cas_noFD; } - /* - * Allows immediate reuse of the port in case we exit early - * + /* * Note: WINSOCK appears to assign a different functionality for - * SO_REUSEADDR compared to other OS. With WINSOCK SO_REUSEADDR indicates - * that other servers can bind to the same TCP port on the same host! + * SO_REUSEADDR compared to other OS. With WINSOCK SO_REUSEADDR indicates + * that simultaneously servers can bind to the same TCP port on the same host! * Also, servers are always enabled to reuse a port immediately after - * they exit. - */ -# ifndef SO_REUSEADDR_DOES_NOT_RELEASE_TCP_PORT + * they exit ( even if SO_REUSEADDR isnt set ). + */ +# ifndef SO_REUSEADDR_ALLOWS_SIMULTANEOUS_TCP_SERVERS_TO_USE_SAME_PORT status = setsockopt ( this->sock, SOL_SOCKET, diff --git a/src/rsrv/caservertask.c b/src/rsrv/caservertask.c index 072b4480b..d9e4cde72 100644 --- a/src/rsrv/caservertask.c +++ b/src/rsrv/caservertask.c @@ -312,7 +312,14 @@ LOCAL int req_server (void) threadSuspendSelf (); } -# ifndef SO_REUSEADDR_DOES_NOT_RELEASE_TCP_PORT + /* + * Note: WINSOCK appears to assign a different functionality for + * SO_REUSEADDR compared to other OS. With WINSOCK SO_REUSEADDR indicates + * that simultaneously servers can bind to the same TCP port on the same host! + * Also, servers are always enabled to reuse a port immediately after + * they exit ( even if SO_REUSEADDR isnt set ). + */ +# ifndef SO_REUSEADDR_ALLOWS_SIMULTANEOUS_TCP_SERVERS_TO_USE_SAME_PORT flag = 1; status = setsockopt ( IOC_sock, SOL_SOCKET, SO_REUSEADDR, (char *) &flag, sizeof (flag) ); diff --git a/src/util/iocLogServer.c b/src/util/iocLogServer.c index f576c8921..aa0fa4744 100644 --- a/src/util/iocLogServer.c +++ b/src/util/iocLogServer.c @@ -47,6 +47,9 @@ * .09 050494 pg HPUX port changes. * .10 021694 joh ANSI C * $Log$ + * Revision 1.39 2000/10/11 22:23:30 jhill + * configure that WINSOCK is very different about SO_REUSEADDR + * * Revision 1.38 2000/08/25 19:44:30 jhill * fixed Linux uses unsigned where int is used on other OS * @@ -243,7 +246,14 @@ int main() return IOCLS_ERROR; } -# ifndef SO_REUSEADDR_DOES_NOT_RELEASE_TCP_PORT + /* + * Note: WINSOCK appears to assign a different functionality for + * SO_REUSEADDR compared to other OS. With WINSOCK SO_REUSEADDR indicates + * that simultaneously servers can bind to the same TCP port on the same host! + * Also, servers are always enabled to reuse a port immediately after + * they exit ( even if SO_REUSEADDR isnt set ). + */ +# ifndef SO_REUSEADDR_ALLOWS_SIMULTANEOUS_TCP_SERVERS_TO_USE_SAME_PORT optval = TRUE; status = setsockopt( pserver->sock, SOL_SOCKET,