Operating System - HP-UX
1830898 Members
2903 Online
110017 Solutions
New Discussion

Socket connect request fails with EINPROGRESS

 
SOLVED
Go to solution
phil atkinson
Advisor

Socket connect request fails with EINPROGRESS

I have a C++ TCP client application which exits when the connect fails

21231: socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = 7
21231: fcntl(7, F_GETFL, 0) = 2
21231: fcntl(7, F_SETFL, 65538) = 0
21231: connect(7, 0x400c4d50, 16) = -1 EINPROGRESS (Operation now in progress)
21231: time(0x7b03be08) = 0x3cc5260a

The manual for connect explains:

[EINPROGRESS] Nonblocking I/O is enabled using O_NONBLOCK, O_NDELAY, or FIOSNBIO, and
the connection cannot be completed
immediately. This is not a failure.
Make the connect() call again a few
seconds later. Alternatively, wait for
completion by calling select() and
selecting for write.

Can someone point me to an example C++/C code of a non-blocking connect request.

Thanks.
4 REPLIES 4
Steve Steel
Honored Contributor

Re: Socket connect request fails with EINPROGRESS

Hi

Go to

http://h21007.www2.hp.com/

Search einprogress

Gives a code example to help.

Is developers portal for languages.


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
phil atkinson
Advisor

Re: Socket connect request fails with EINPROGRESS

Thanks for the answer but my client is failing on the connect request. I wanted to know how to use the select call to determine when the socket is connected for reading and writing.
IT Response
Esteemed Contributor
Solution

Re: Socket connect request fails with EINPROGRESS

There is an example on page 409 of Unix Network Programming, Vol I, 2E W.Richard Stephens.

The bottom line is connect() will return 0 if connected immediately (not likely) , EINPROGRESS if not.

Then, select() returns readable for the socket after the connection is complete.
IT Response
Esteemed Contributor

Re: Socket connect request fails with EINPROGRESS

Sorry, it's readable or writeable.

There more to it than that for complete error checking, but those are the basics.