summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2014-03-05 10:20:09 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2014-03-05 10:20:09 (GMT)
commit91e8a8f60c91ad11df3a1c00d36184b9bc0c9947 (patch)
tree65e79d2030eed3a8b8776d77e091aacb70a4c910 /win
parent312c80abf4c34b3313aae1c532e5621066e8bd1c (diff)
downloadtcl-91e8a8f60c91ad11df3a1c00d36184b9bc0c9947.zip
tcl-91e8a8f60c91ad11df3a1c00d36184b9bc0c9947.tar.gz
tcl-91e8a8f60c91ad11df3a1c00d36184b9bc0c9947.tar.bz2
Next async connect try works. Reset error and move notifier before connect.
Diffstat (limited to 'win')
-rw-r--r--win/tclWinSock.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index 6620def..2da50f5 100644
--- a/win/tclWinSock.c
+++ b/win/tclWinSock.c
@@ -1214,6 +1214,11 @@ CreateClientSocket(
DEBUG("closesocket");
closesocket(infoPtr->sockets->fd);
}
+
+ /*
+ * Reset last error from last try
+ */
+ infoPtr->lastError = 0;
infoPtr->sockets->fd = socket(infoPtr->myaddr->ai_family, SOCK_STREAM, 0);
if (infoPtr->sockets->fd == INVALID_SOCKET) {
@@ -1249,11 +1254,13 @@ CreateClientSocket(
* Set the socket into nonblocking mode if the connect should
* be done in the background.
*/
- if (async && ioctlsocket(infoPtr->sockets->fd, (long) FIONBIO, &flag)
- == SOCKET_ERROR) {
- DEBUG("FIONBIO");
- TclWinConvertError((DWORD) WSAGetLastError());
- continue;
+ if (async) {
+ ThreadSpecificData *tsdPtr = TclThreadDataKeyGet(&dataKey);
+ infoPtr->selectEvents |= FD_CONNECT;
+
+ ioctlsocket(infoPtr->sockets->fd, (long) FIONBIO, &flag);
+ SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
+ (LPARAM) infoPtr);
}
/*
@@ -1269,13 +1276,7 @@ CreateClientSocket(
// fprintf(stderr,"error = %lu\n", error);
#endif
if (error == WSAEWOULDBLOCK) {
- ThreadSpecificData *tsdPtr = TclThreadDataKeyGet(&dataKey);
DEBUG("WSAEWOULDBLOCK");
- infoPtr->selectEvents |= FD_CONNECT;
-
- ioctlsocket(infoPtr->sockets->fd, (long) FIONBIO, &flag);
- SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
- (LPARAM) infoPtr);
return TCL_OK;
reenter:
Tcl_SetErrno(infoPtr->lastError);