diff options
Diffstat (limited to 'win/tclWinSock.c')
-rw-r--r-- | win/tclWinSock.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/win/tclWinSock.c b/win/tclWinSock.c index e42cafd..01cefb5 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -1993,7 +1993,7 @@ TcpConnect( /* *---------------------------------------------------------------------- * - * Tcl_OpenTcpClient -- + * Tcl_OpenTcpClient, Tcl_OpenTcpClientEx -- * * Opens a TCP client socket and creates a channel around it. * @@ -2018,6 +2018,25 @@ Tcl_OpenTcpClient( * connect. Otherwise we do a blocking * connect. */ { + char service[TCL_INTEGER_SPACE], myservice[TCL_INTEGER_SPACE]; + + TclFormatInt(service, port); + TclFormatInt(myservice, myport); + + return Tcl_OpenTcpClientEx(interp, service, host, myaddr, myservice, async!=0); +} + +Tcl_Channel +Tcl_OpenTcpClientEx( + 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; @@ -2041,8 +2060,8 @@ Tcl_OpenTcpClient( * Do the name lookups for the local and remote addresses. */ - if (!TclCreateSocketAddress(interp, &addrlist, host, port, 0, &errorMsg) - || !TclCreateSocketAddress(interp, &myaddrlist, myaddr, myport, 1, + if (!TclCreateSocketAddress(interp, &addrlist, host, service, 0, &errorMsg) + || !TclCreateSocketAddress(interp, &myaddrlist, myaddr, myservice, 1, &errorMsg)) { if (addrlist != NULL) { freeaddrinfo(addrlist); @@ -2057,7 +2076,7 @@ Tcl_OpenTcpClient( statePtr = NewSocketInfo(INVALID_SOCKET); statePtr->addrlist = addrlist; statePtr->myaddrlist = myaddrlist; - if (async) { + if (flags&1) { SET_BITS(statePtr->flags, TCP_ASYNC_CONNECT); } @@ -2201,8 +2220,8 @@ Tcl_OpenTcpServerEx( goto error; } - if (!TclCreateSocketAddress(interp, &addrlist, myHost, port, 1, - &errorMsg)) { + if (!TclCreateSocketAddress(interp, &addrlist, myHost, service, 1, + &errorMsg)) { goto error; } |