The ultimate socket library for C and C++, supporting TCP, UDP and Unix sockets (DGRAM and STREAM) on Linux, FreeBSD, Solaris. See also my uvco library for a refreshed version!
When SOCK_NONBLOCK is set on a socket, it will always return with one of these three errnos: EINPROGRESS, EALREADY, EINTR, so libsocket would reject the connection as failed. With this change, it will allow through those connections if the proper flag is set and it gets one of the three accepted errors. An important note though, this will return successfully even if the target socket -doesn't exist at all-, a true failure. The way to properly check if a nonblocking socket is connected, is to see if we can read/write to it. If we can, great! If not, we probably didn't connect correctly.
When SOCK_NONBLOCK is set on a socket, it will always return with one of these three errnos: EINPROGRESS, EALREADY, EINTR, so libsocket would reject the connection as failed. With this change, it will allow through those connections if the proper flag is set and it gets one of the three accepted errors. An important note though, this will return successfully even if the target socket -doesn't exist at all-, a true failure. The way to properly check if a nonblocking socket is connected, is to see if we can read/write to it. If we can, great! If not, we probably didn't connect correctly.