7

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

tcp api is : connect

Syedsma
  • 1,183
  • 5
  • 17
  • 22
  • 1
    It means you've got an asynchronous thing going on, and it's not done yet. Please specify what system call you're talking about if you want constructive answers. – Mat Nov 26 '11 at 11:09
  • I already pointed you to how to go on by adding the man pages extract on how to get more detailed info on this here: http://stackoverflow.com/q/8277540/694576 – alk Nov 26 '11 at 11:19
  • Anyway, showing us at least your client's code would surely help ... – alk Nov 26 '11 at 11:24

3 Answers3

22

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.

ninjalj
  • 42,493
  • 9
  • 106
  • 148
  • Right now I am chking only for EAGAIN/EWOULDBLOCK error in non block, So In non-blocking , If have to do select for EINPROGRESS error along with EAGAIN/EWOULDBLOCK error also – Syedsma Nov 28 '11 at 13:02
  • 1
    @Syedsma: only connect() returns EINPROGRESS. – ninjalj Nov 28 '11 at 18:53
  • Just wondering, if the select returns true (select for write for example), connect succeeded but the last errno to be set was EINPROGRESS. Should this error be ignored in that case ? – Bionix1441 Jul 14 '16 at 09:16
8

You are obviously using non-blocking sockets and you need to use select() or poll() to determine when you can write (connect is a form of write) to the socket. It's the same when you wish to actually write data to the connected socket; you don't just write and connect when you feel like it, you ask the socket to tell you when you can do things and in the meantime you do something else (the idea of asynchronous socket operations).

Check your manpage for the absolute truth about available error codes:

$ man connect

[EINPROGRESS] The socket is non-blocking and the connection cannot be completed immediately. It is possible to select(2) for completion by selecting the socket for writing.

trojanfoe
  • 120,358
  • 21
  • 212
  • 242
0

I got this error when trying to connect (using FFMPEG) to an invalid local IP address (i.e. incorrect subnet), correcting the host fixed the issue

Kyle Redfearn
  • 2,172
  • 16
  • 34
  • I don't think you'll get EINPROGRESS for that though would you? – rogerdpack Aug 20 '18 at 19:03
  • I am not calling `connect` directly I am using a networking client: `FFMPEG`. It might be a bug in the implementation of the client. I can only report what I saw and how it was fixed. Hopefully is helps another person like it did me. – Kyle Redfearn Aug 21 '18 at 20:33