It is possible to do non-blocking IO on sockets by setting the O_NONBLOCK flag on a
socket file descriptor using fcntl(2). Then all operations that would block will
(usually) return with EAGAIN (operation should be retried later); connect(2) will
return EINPROGRESS error. The user can then wait for various events via poll(2) or
select(2).