|
|
@@ -702,17 +702,31 @@ int doconnect(struct clientparam * param){
|
|
|
}
|
|
|
|
|
|
if(param->operation >= 256 || (param->operation & CONNECT)){
|
|
|
+ struct pollfd fds[1];
|
|
|
#ifdef _WIN32
|
|
|
unsigned long ul = 1;
|
|
|
+ ioctlsocket(param->remsock, FIONBIO, &ul);
|
|
|
+#else
|
|
|
+ socklen_t us = sizeof(ul);
|
|
|
+ fcntl(param->remsock,F_SETFL,O_NONBLOCK);
|
|
|
#endif
|
|
|
if(so._connect(param->remsock,(struct sockaddr *)¶m->sinsr,SASIZE(¶m->sinsr))) {
|
|
|
+ if(errno != EAGAIN) return (13);
|
|
|
+ }
|
|
|
+ memset(fds, 0, sizeof(fds));
|
|
|
+ fds[0].fd = param->remsock;
|
|
|
+ fds[0].events = POLLOUT;
|
|
|
+ if(so._poll(fds, 1, conf.timeouts[STRING_S]*1000) <= 0) {
|
|
|
return (13);
|
|
|
}
|
|
|
- param->nconnects++;
|
|
|
-#ifdef _WIN32
|
|
|
- ioctlsocket(param->remsock, FIONBIO, &ul);
|
|
|
-#else
|
|
|
- fcntl(param->remsock,F_SETFL,O_NONBLOCK);
|
|
|
+#ifndef _WIN32
|
|
|
+#ifdef SO_ERROR
|
|
|
+ getsockopt(param->remsock, SOL_SOCKET, SO_ERROR, &ul, &us);
|
|
|
+
|
|
|
+ if (ul != 0) {
|
|
|
+ return (13);
|
|
|
+ }
|
|
|
+#endif
|
|
|
#endif
|
|
|
}
|
|
|
size = sizeof(param->sinsl);
|