summaryrefslogtreecommitdiffstats
path: root/generic/tclIOCmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclIOCmd.c')
-rw-r--r--generic/tclIOCmd.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c
index 883c6b7..b4696fd 100644
--- a/generic/tclIOCmd.c
+++ b/generic/tclIOCmd.c
@@ -1485,12 +1485,15 @@ Tcl_SocketObjCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
static const char *const socketOptions[] = {
- "-async", "-myaddr", "-myport", "-server", "-reuseport", NULL
+ "-async", "-myaddr", "-myport", "-server", "-reuseaddr", "-reuseport",
+ NULL
};
enum socketOptions {
- SKT_ASYNC, SKT_MYADDR, SKT_MYPORT, SKT_SERVER, SKT_REUSEPORT
+ SKT_ASYNC, SKT_MYADDR, SKT_MYPORT, SKT_SERVER, SKT_REUSEADDR,
+ SKT_REUSEPORT
};
- int optionIndex, a, server = 0, port, myport = 0, async = 0, flags = 0;
+ int optionIndex, a, server = 0, port, myport = 0, async = 0;
+ unsigned int flags = 0;
const char *host, *myaddr = NULL;
Tcl_Obj *script = NULL;
Tcl_Channel chan;
@@ -1557,8 +1560,11 @@ Tcl_SocketObjCmd(
}
script = objv[a];
break;
+ case SKT_REUSEADDR:
+ flags |= TCL_TCPSERVER_REUSEADDR;
+ break;
case SKT_REUSEPORT:
- flags |= 1;
+ flags |= TCL_TCPSERVER_REUSEPORT;
break;
default:
Tcl_Panic("Tcl_SocketObjCmd: bad option index to SocketOptions");
@@ -1583,7 +1589,14 @@ Tcl_SocketObjCmd(
"?-myaddr addr? ?-myport myport? ?-async? host port");
iPtr->flags |= INTERP_ALTERNATE_WRONG_ARGS;
Tcl_WrongNumArgs(interp, 1, objv,
- "-server command ?-myaddr addr? port");
+ "-server command ?-reuseaddr? ?-reuseport? ?-myaddr addr? port");
+ return TCL_ERROR;
+ }
+
+ if (!server && flags != 0) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "options -reuseaddr and -reuseport are only valid for servers",
+ -1));
return TCL_ERROR;
}