IWETHEY v. 0.3.0 | TODO
1,095 registered users | 1 active user | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Fun with sockets and select
The Scene: asynchronous socket creation

The Issue: select should return, and FD_ISSET should allow us to determine if the connection failed by checking the exceptions

The Reality: This works in Solaris (and I believe is posix-standard), but Linux seems to always return writable after the select, but wants us to check getsockopts to see if it is really writable.

Any socket gurus out there who can clue me in?
Regards,

-scott anderson
New Re: Fun with sockets and select
If by an asynchronous request you mean non-blocking, then it is not reasonable to be expecting correct status. What asynchronous means is "do this for me, but come right back because I have other things to do". "I'll check back later to see how you did". A blocking request means do "this for me and I will wait until you do it or know why you can't".

It looks like Solaris is simply doing a blocking request, i.e. it's *not* asynchronous.

I did some socket stuff in 1995 but I'm no socket guru.
Alex

Men never do evil so completely and cheerfully as when they do it from religious conviction. -- Blaise Pascal (1623-1662)
New Nope.
We're waiting after the connect() is issued for a certain delay (2 seconds in this case). During the delay, a connect signal can occur, or the wait can time out. At the end of the timeout, the code checks the exception mask to see if an exception occurred, or if the socket indicates write status.

Last night I discovered that EINPROGRESS on Linux will always eventually mean that the socket becomes writable -- an exception will never be set. You then have to check getsockopt(sock, SOL_SOCKET, SO_ERROR, &buf, &size) to see if a failed connection error was set. Really strange.
Regards,

-scott anderson
     Fun with sockets and select - (admin) - (2)
         Re: Fun with sockets and select - (a6l6e6x) - (1)
             Nope. - (admin)

Where did you want to go yesterday?
35 ms