diff options
author | limeboy <that.lemon+tcl@gmai.com> | 2016-12-14 15:49:27 (GMT) |
---|---|---|
committer | limeboy <that.lemon+tcl@gmai.com> | 2016-12-14 15:49:27 (GMT) |
commit | fdc5267c5f6488e6f8065453fc078e0ebc45d861 (patch) | |
tree | 252d57e9f2c63147b2b616e30c2c54e1fe47a086 /win/tclWinSock.c | |
parent | bba3b008ba9e94fbe9a9ffce00aaf90077136fca (diff) | |
download | tcl-fdc5267c5f6488e6f8065453fc078e0ebc45d861.zip tcl-fdc5267c5f6488e6f8065453fc078e0ebc45d861.tar.gz tcl-fdc5267c5f6488e6f8065453fc078e0ebc45d861.tar.bz2 |
Make OpenTcpServerEx accept a 'service' string parameter instead of a port.
Diffstat (limited to 'win/tclWinSock.c')
-rw-r--r-- | win/tclWinSock.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/win/tclWinSock.c b/win/tclWinSock.c index af22cf8..5e0d7c8 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -2037,7 +2037,7 @@ Tcl_MakeTcpClientChannel( Tcl_Channel Tcl_OpenTcpServerEx( Tcl_Interp *interp, /* For error reporting - may be NULL. */ - int port, /* Port number to open. */ + const char *service, /* Port number to open. */ const char *myHost, /* Name of local host. */ unsigned int flags, /* Flags. */ Tcl_TcpAcceptProc *acceptProc, @@ -2053,7 +2053,7 @@ Tcl_OpenTcpServerEx( char channelName[SOCK_CHAN_LENGTH]; u_long flag = 1; /* Indicates nonblocking mode. */ const char *errorMsg = NULL; - int optvalue; + int optvalue, port; if (TclpHasSockets(interp) != TCL_OK) { return NULL; @@ -2073,6 +2073,11 @@ Tcl_OpenTcpServerEx( * Construct the addresses for each end of the socket. */ + if (TclSockGetPort(interp, service, "tcp", &port) != TCL_OK) { + errorMsg = "invalid port number"; + goto error; + } + if (!TclCreateSocketAddress(interp, &addrlist, myHost, port, 1, &errorMsg)) { goto error; } |