diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-01-10 14:35:13 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-01-10 14:35:13 (GMT) |
commit | 211801be532da7c72b73cf0311dc07eaef32aac5 (patch) | |
tree | c75195c0e09450101b9aabe6f16dc009a0c0c0aa /win/tclWinSock.c | |
parent | 087ee7ed0d134cda28132343b258eee2afc60261 (diff) | |
download | tcl-211801be532da7c72b73cf0311dc07eaef32aac5.zip tcl-211801be532da7c72b73cf0311dc07eaef32aac5.tar.gz tcl-211801be532da7c72b73cf0311dc07eaef32aac5.tar.bz2 |
Further experimental follow-up: Add internal function TclOpenTcpClientEx(), as companion to Tcl_OpenTcpServerEx(). Should be exported through new TIP.tip_456
Diffstat (limited to 'win/tclWinSock.c')
-rw-r--r-- | win/tclWinSock.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/win/tclWinSock.c b/win/tclWinSock.c index b2d77a1..8545cdd 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -1873,7 +1873,7 @@ out: /* *---------------------------------------------------------------------- * - * Tcl_OpenTcpClient -- + * Tcl_OpenTcpClient, TclOpenTcpClientEx -- * * Opens a TCP client socket and creates a channel around it. * @@ -1898,15 +1898,29 @@ Tcl_OpenTcpClient( * connect. Otherwise we do a blocking * connect. */ { - TcpState *statePtr; - const char *errorMsg = NULL; - struct addrinfo *addrlist = NULL, *myaddrlist = NULL; - char channelName[SOCK_CHAN_LENGTH]; char service[TCL_INTEGER_SPACE], myservice[TCL_INTEGER_SPACE]; TclFormatInt(service, port); TclFormatInt(myservice, myport); + return TclOpenTcpClientEx(interp, service, host, myaddr, myservice, async!=0); +} + +Tcl_Channel +TclOpenTcpClientEx( + Tcl_Interp *interp, /* For error reporting; can be NULL. */ + const char *service, /* Port number to open. */ + const char *host, /* Host on which to open port. */ + const char *myaddr, /* Client-side address */ + const char *myservice, /* Client-side port */ + unsigned int flags) /* If nonzero, attempt to do an asynchronous + * connect. Otherwise we do a blocking + * connect. */ +{ + TcpState *statePtr; + const char *errorMsg = NULL; + struct addrinfo *addrlist = NULL, *myaddrlist = NULL; + char channelName[SOCK_CHAN_LENGTH]; if (TclpHasSockets(interp) != TCL_OK) { return NULL; @@ -1942,7 +1956,7 @@ Tcl_OpenTcpClient( statePtr = NewSocketInfo(INVALID_SOCKET); statePtr->addrlist = addrlist; statePtr->myaddrlist = myaddrlist; - if (async) { + if (flags&1) { statePtr->flags |= TCP_ASYNC_CONNECT; } |