diff options
author | limeboy <that.lemon+tcl@gmai.com> | 2016-11-25 14:53:20 (GMT) |
---|---|---|
committer | limeboy <that.lemon+tcl@gmai.com> | 2016-11-25 14:53:20 (GMT) |
commit | 8fe50e3f91ec232823ba032f24dabbaa7c9f298c (patch) | |
tree | 31adda353bf78e0619069a8a22f549bdab1adbf1 /win | |
parent | 3d5c28f5270e4958bcec2e6e52425a5fae5f8cc4 (diff) | |
download | tcl-8fe50e3f91ec232823ba032f24dabbaa7c9f298c.zip tcl-8fe50e3f91ec232823ba032f24dabbaa7c9f298c.tar.gz tcl-8fe50e3f91ec232823ba032f24dabbaa7c9f298c.tar.bz2 |
Windows support and minor touchups to the documentation.
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinSock.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/win/tclWinSock.c b/win/tclWinSock.c index b228730..af22cf8 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -2039,7 +2039,7 @@ Tcl_OpenTcpServerEx( Tcl_Interp *interp, /* For error reporting - may be NULL. */ int port, /* Port number to open. */ const char *myHost, /* Name of local host. */ - unsigned int flags, /* Flags (not used) */ + unsigned int flags, /* Flags. */ Tcl_TcpAcceptProc *acceptProc, /* Callback for accepting connections from new * clients. */ @@ -2053,6 +2053,7 @@ Tcl_OpenTcpServerEx( char channelName[SOCK_CHAN_LENGTH]; u_long flag = 1; /* Indicates nonblocking mode. */ const char *errorMsg = NULL; + int optvalue; if (TclpHasSockets(interp) != TCL_OK) { return NULL; @@ -2111,9 +2112,17 @@ Tcl_OpenTcpServerEx( } /* - * Bind to the specified port. Note that we must not call - * setsockopt with SO_REUSEADDR or SO_REUSEPORT because Microsoft - * allows addresses and ports to be reused even if they are still in use. + * The SO_REUSEADDR option on Windows behaves like SO_REUSEPORT on unix + * systems. + */ + if (flags & TCL_TCPSERVER_REUSEPORT) { + optvalue = 1; + (void) setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + (char *) &optvalue, sizeof(optvalue)); + } + + /* + * Bind to the specified port. * * Bind should not be affected by the socket having already been * set into nonblocking mode. If there is trouble, this is one |