diff options
-rw-r--r-- | doc/socket.n | 10 | ||||
-rw-r--r-- | tests/ioCmd.test | 2 | ||||
-rw-r--r-- | unix/tclUnixSock.c | 12 | ||||
-rw-r--r-- | win/tclWinSock.c | 14 |
4 files changed, 17 insertions, 21 deletions
diff --git a/doc/socket.n b/doc/socket.n index 4506181..b7b3228 100644 --- a/doc/socket.n +++ b/doc/socket.n @@ -208,15 +208,13 @@ This option is not supported by server sockets. For client sockets, this option .TP \fB\-keepalive\fR . -This options sets or queries the TCP keepalive option on the socket as 1 if +This option sets or queries the TCP keepalive option on the socket as 1 if keepalive is turned on, 0 otherwise. .TP -\fB\-nagle\fR +\fB\-nodelay\fR . -This options sets or queries the TCP nodelay option (aka the Nagle algorithm) -When 1 the Nagle algorithm is turned on, 0 otherwise. Caution: the logic is -reversed here, i.e. when the option is 0, the underlying system call asserts -the TCP_NODELAY setting. +This option sets or queries the TCP nodelay option on the socket as 1 if +nodelay is turned on, 0 otherwise. .PP .SH "EXAMPLES" .PP diff --git a/tests/ioCmd.test b/tests/ioCmd.test index f911846..02a0428 100644 --- a/tests/ioCmd.test +++ b/tests/ioCmd.test @@ -306,7 +306,7 @@ test iocmd-8.15 {fconfigure command / tcp channel} -constraints {socket unixOrWi close $srv unset cli srv port rename iocmdSRV {} -} -returnCodes error -result [expectedOpts "-blah" {-connecting -keepalive -nagle -peername -sockname}] +} -returnCodes error -result [expectedOpts "-blah" {-connecting -keepalive -nodelay -peername -sockname}] test iocmd-8.16 {fconfigure command / tcp channel} -constraints socket -setup { set srv [socket -server iocmdSRV -myaddr 127.0.0.1 0] set port [lindex [fconfigure $srv -sockname] 2] diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c index 7f22796..e904cfd 100644 --- a/unix/tclUnixSock.c +++ b/unix/tclUnixSock.c @@ -864,13 +864,12 @@ TcpSetOptionProc( return TCL_OK; } if ((len > 1) && (optionName[1] == 'n') && - (strncmp(optionName, "-nagle", len) == 0)) { + (strncmp(optionName, "-nodelay", len) == 0)) { int val = 0, ret; if (Tcl_GetBoolean(interp, value, &val) != TCL_OK) { return TCL_ERROR; } - val = !val; /* Nagle ain't nodelay */ #if defined(SOL_TCP) && defined(TCP_NODELAY) ret = setsockopt(statePtr->fds.fd, SOL_TCP, TCP_NODELAY, (const char *) &val, sizeof(int)); @@ -888,7 +887,7 @@ TcpSetOptionProc( } return TCL_OK; } - return Tcl_BadChannelOption(interp, optionName, "keepalive nagle"); + return Tcl_BadChannelOption(interp, optionName, "keepalive nodelay"); } /* @@ -1074,18 +1073,17 @@ TcpGetOptionProc( } if ((len == 0) || ((len > 1) && (optionName[1] == 'n') && - (strncmp(optionName, "-nagle", len) == 0))) { + (strncmp(optionName, "-nodelay", len) == 0))) { socklen_t size; int opt = 0; if (len == 0) { - Tcl_DStringAppendElement(dsPtr, "-nagle"); + Tcl_DStringAppendElement(dsPtr, "-nodelay"); } #if defined(SOL_TCP) && defined(TCP_NODELAY) getsockopt(statePtr->fds.fd, SOL_TCP, TCP_NODELAY, (char *) &opt, &size); #endif - opt = !opt; /* Nagle ain't nodelay */ Tcl_DStringAppendElement(dsPtr, opt ? "1" : "0"); if (len > 0) { return TCL_OK; @@ -1094,7 +1092,7 @@ TcpGetOptionProc( if (len > 0) { return Tcl_BadChannelOption(interp, optionName, - "connecting keepalive nagle peername sockname"); + "connecting keepalive nodelay peername sockname"); } return TCL_OK; diff --git a/win/tclWinSock.c b/win/tclWinSock.c index 8d16b5c..56d2ba4 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -1220,14 +1220,14 @@ TcpSetOptionProc( return TCL_OK; } if ((len > 1) && (optionName[1] == 'n') && - (strncmp(optionName, "-nagle", len) == 0)) { + (strncmp(optionName, "-nodelay", len) == 0)) { BOOL val; int boolVar, rtn; if (Tcl_GetBoolean(interp, value, &boolVar) != TCL_OK) { return TCL_ERROR; } - val = boolVar ? FALSE : TRUE; + val = boolVar ? TRUE : FALSE; rtn = setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *) &val, sizeof(BOOL)); if (rtn != 0) { @@ -1241,7 +1241,7 @@ TcpSetOptionProc( } return TCL_OK; } - return Tcl_BadChannelOption(interp, optionName, "keepalive nagle"); + return Tcl_BadChannelOption(interp, optionName, "keepalive nodelay"); } /* @@ -1533,17 +1533,17 @@ TcpGetOptionProc( } if ((len == 0) || ((len > 1) && (optionName[1] == 'n') && - (strncmp(optionName, "-nagle", len) == 0))) { + (strncmp(optionName, "-nodelay", len) == 0))) { int optlen; BOOL opt = FALSE; if (len == 0) { sock = statePtr->sockets->fd; - Tcl_DStringAppendElement(dsPtr, "-nagle"); + Tcl_DStringAppendElement(dsPtr, "-nodelay"); } optlen = sizeof(BOOL); getsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&opt, &optlen); - Tcl_DStringAppendElement(dsPtr, opt ? "0" : "1"); + Tcl_DStringAppendElement(dsPtr, opt ? "1" : "0"); if (len > 0) { return TCL_OK; } @@ -1551,7 +1551,7 @@ TcpGetOptionProc( if (len > 0) { return Tcl_BadChannelOption(interp, optionName, - "connecting keepalive nagle peername sockname"); + "connecting keepalive nodelay peername sockname"); } return TCL_OK; |