Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are possible reason for socket error EINPROGRESS in solaris?

What are possible reason for socket error EINPROGRESS in Solaris? How we can check the root cause?

tcp api is : connect

like image 870
Syedsma Avatar asked Nov 26 '11 11:11

Syedsma


1 Answers

You have a non-blocking socket and you are calling connect() in it. Since connect() needs the 3-way handshake to happen (so a network roundtrip), it either blocks waiting for the SYN-ACK in blocking sockets, or gives you some indication that it hasn't succeded yet in non-blocking sockets. Normally, non-blocking sockets return EAGAIN/EWOULDBLOCK to tell you that they couldn't progress and you should try again: this is not exactly your case, connect() returns EAGAIN/EWOULDBLOCK when there are no free ephemeral ports to tell you that you should try again later; so there is another error for non-blocking connect: EINPROGRESS, which tells you that the operation is in progress and you should check its status later.

To check the status later, the socket will become ready for writability, so you can use select()/poll()/... to test for that, after which you'll have to getsockopt(...SO_ERROR...) to get the success/failure status of your connect() operation.

like image 70
ninjalj Avatar answered Nov 06 '22 12:11

ninjalj