fix timeout by checking the socket for errors
In the old situation when the connect didn't immediately return, the socket was placed in a select. An error was throws only when the socket was in the exceptset. However, sockets are only in the exceptset in very particular cases (see man select). Unable to connect is not one of those cases.
Therefore to actually check if a connection was refused, the error status must be checked with getsockopt.
Also see (https://stackoverflow.com/questions/2597608/c-socket-connection-timeout/2597774#2597774)
Closes: clean-and-itasks/iTasks-SDK#348