summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorlimeboy <that.lemon+tcl@gmai.com>2016-12-14 15:49:27 (GMT)
committerlimeboy <that.lemon+tcl@gmai.com>2016-12-14 15:49:27 (GMT)
commit2e467a4c9a0cb63cb152e21bb05eb3493ea3ca14 (patch)
tree252d57e9f2c63147b2b616e30c2c54e1fe47a086 /unix
parent13a4d32330a2ec5af486c1fa5fb09338da3af8db (diff)
downloadtcl-2e467a4c9a0cb63cb152e21bb05eb3493ea3ca14.zip
tcl-2e467a4c9a0cb63cb152e21bb05eb3493ea3ca14.tar.gz
tcl-2e467a4c9a0cb63cb152e21bb05eb3493ea3ca14.tar.bz2
Make OpenTcpServerEx accept a 'service' string parameter instead of a port.
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixSock.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 187c157..8e97543 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -1422,7 +1422,7 @@ TclpMakeTcpClientChannelMode(
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,
@@ -1430,7 +1430,7 @@ Tcl_OpenTcpServerEx(
* clients. */
ClientData acceptProcData) /* Data for the callback. */
{
- int status = 0, sock = -1, optvalue, chosenport;
+ int status = 0, sock = -1, optvalue, port, chosenport;
struct addrinfo *addrlist = NULL, *addrPtr; /* socket address */
TcpState *statePtr = NULL;
char channelName[SOCK_CHAN_LENGTH];
@@ -1476,6 +1476,11 @@ Tcl_OpenTcpServerEx(
retry++;
chosenport = 0;
+ if (TclSockGetPort(interp, service, "tcp", &port) != TCL_OK) {
+ errorMsg = "invalid port number";
+ goto error;
+ }
+
if (!TclCreateSocketAddress(interp, &addrlist, myHost, port, 1, &errorMsg)) {
my_errno = errno;
goto error;