Skip to content

Commit b4f5193

Browse files
authored
Merge pull request #80 from nick-piotrowski/nick-piotrowski-patch-1
Allow non-blocking client sockets to be created
2 parents 1f28e5e + 81c412d commit b4f5193

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

C/inet/libinetsocket.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,11 @@ int create_inet_stream_socket(const char *host, const char *service,
201201
if (sfd < 0) // Error!!!
202202
continue;
203203

204-
if (-1 != connect(sfd, result_check->ai_addr,
205-
result_check->ai_addrlen)) // connected without error
206-
break;
207-
204+
int CON_RES = connect(sfd, result_check->ai_addr,
205+
result_check->ai_addrlen);
206+
if ((CON_RES != -1) || (CON_RES == -1 && (flags |= SOCK_NONBLOCK) && ((errno == EINPROGRESS) || (errno == EALREADY) || (errno == EINTR)))) // connected without error, or, connected with errno being one of these important states
207+
break;
208+
208209
close(sfd);
209210
}
210211

0 commit comments

Comments
 (0)