summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2014-10-17 14:28:46 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2014-10-17 14:28:46 (GMT)
commit0237d15593de152f8d82bd4b852ed260d73dfbd5 (patch)
treeadde55fda8a9510431640463f98f56fe18a3af43 /unix
parent9acec29bc1cc79293e2760411a3f07ffdd8113e1 (diff)
parentfc47c8aae5f8c68455ee588cfbe4f707e91bde7d (diff)
downloadtcl-tip_428.zip
tcl-tip_428.tar.gz
tcl-tip_428.tar.bz2
Merge trunktip_428
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixSock.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 3afdb91..a9752ea 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -854,7 +854,20 @@ TcpGetOptionProc(
address peername;
socklen_t size = sizeof(peername);
- if (getpeername(statePtr->fds.fd, &peername.sa, &size) >= 0) {
+ if ( (statePtr->flags & TCP_ASYNC_CONNECT) ) {
+ /*
+ * In async connect output an empty string
+ */
+ if (len == 0) {
+ Tcl_DStringAppendElement(dsPtr, "-peername");
+ Tcl_DStringAppendElement(dsPtr, "");
+ } else {
+ return TCL_OK;
+ }
+ } else if (getpeername(statePtr->fds.fd, &peername.sa, &size) >= 0) {
+ /*
+ * Peername fetch succeeded - output list
+ */
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-peername");
Tcl_DStringStartSublist(dsPtr);
@@ -894,11 +907,18 @@ TcpGetOptionProc(
Tcl_DStringAppendElement(dsPtr, "-sockname");
Tcl_DStringStartSublist(dsPtr);
}
- for (fds = &statePtr->fds; fds != NULL; fds = fds->next) {
- size = sizeof(sockname);
- if (getsockname(fds->fd, &(sockname.sa), &size) >= 0) {
- found = 1;
- TcpHostPortList(interp, dsPtr, sockname, size);
+ if ( (statePtr->flags & TCP_ASYNC_CONNECT) ) {
+ /*
+ * In async connect output an empty string
+ */
+ found = 1;
+ } else {
+ for (fds = &statePtr->fds; fds != NULL; fds = fds->next) {
+ size = sizeof(sockname);
+ if (getsockname(fds->fd, &(sockname.sa), &size) >= 0) {
+ found = 1;
+ TcpHostPortList(interp, dsPtr, sockname, size);
+ }
}
}
if (found) {