summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixSock.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-01-10 14:35:13 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-01-10 14:35:13 (GMT)
commit8c52e2d45db4862de7e7506197321a6a111c65f6 (patch)
treec75195c0e09450101b9aabe6f16dc009a0c0c0aa /unix/tclUnixSock.c
parentd61a4c17579c4a064d692e670e06c98c45baff80 (diff)
downloadtcl-8c52e2d45db4862de7e7506197321a6a111c65f6.zip
tcl-8c52e2d45db4862de7e7506197321a6a111c65f6.tar.gz
tcl-8c52e2d45db4862de7e7506197321a6a111c65f6.tar.bz2
Further experimental follow-up: Add internal function TclOpenTcpClientEx(), as companion to Tcl_OpenTcpServerEx(). Should be exported through new TIP.
Diffstat (limited to 'unix/tclUnixSock.c')
-rw-r--r--unix/tclUnixSock.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 63bccae..50452e9 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -1283,19 +1283,30 @@ 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];
- /*
- * Do the name lookups for the local and remote addresses.
- */
-
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 (!TclCreateSocketAddress(interp, &addrlist, host, service, 0, &errorMsg)
|| !TclCreateSocketAddress(interp, &myaddrlist, myaddr, myservice, 1,
&errorMsg)) {
@@ -1314,7 +1325,7 @@ Tcl_OpenTcpClient(
*/
statePtr = ckalloc(sizeof(TcpState));
memset(statePtr, 0, sizeof(TcpState));
- statePtr->flags = async ? TCP_ASYNC_CONNECT : 0;
+ statePtr->flags = (flags&1) ? TCP_ASYNC_CONNECT : 0;
statePtr->cachedBlocking = TCL_MODE_BLOCKING;
statePtr->addrlist = addrlist;
statePtr->myaddrlist = myaddrlist;