Hi All,
I am trying to use non blocking connect method for connecting to a
range of hosts. Now I am observing a strange behavior on Linux
(Linux.2.4.9).
Algorithm:
I am trying to connect to an array of sockets using a separate connect
call for each of them.
for( some range of socket fds)
connect(); //all these sockets are non blocking.
this connect returns immediately. Now if there is no error, I assign
this socket FD to a socket fd set, which is eventually used by select.
Then I call select () passing this socket fd set. While doing this I
make sure that numbers of FDS in my set are < FD_SETSIZE.
After I come out of the select call, I check for return value and if
its > 0 then I call getsockopt on each of the socket fds in the set(
which pass FD_ISSET ).
If getsockopt ( with SOL_SOCKET and SO_ERROR) return error then I
assume Connect failed.
Now the problem is: On Linux 2.4.9
If the range of FDs I am polling on is big, then for some correct
hosts(which are reachable and have port open) getsockopt returns error
113 (EHOSTUNREACH).
On the other hand for small range of FDs for the same host getsockopt
succeeds.
Why is this anomalous behavior observed? Is there a different and
correct way available?
Waiting for reply.
Sucheta.
|