Re: O_NONBLOCK & connect() not blocking
Re: O_NONBLOCK & connect() not blocking
- Subject: Re: O_NONBLOCK & connect() not blocking
- From: Quinn <email@hidden>
- Date: Thu, 13 Jul 2006 14:16:23 +0100
At 11:35 +0100 12/7/06, Mark Thomas wrote:
Is there any reason why connect() always seems to block for about 30-40
seconds regardless if you are setting the O_NONBLOCK flag via fcntl &
F_SETFL and using select() to detect the connection has happened.
I remember seeing something like this before, but I can't find the
reference. My guess is that you're binding the socket to a specific
local port number. If so, stop doing that and see if it changes
things.
IIRC if you bind to a specific port number and connect multiple times
to the same remote socket/port, the second connect gets blocked
waiting for the first to leave TIMEWAIT. Remember that TCP
connections are uniquely identified by the 4-uple of
localIP/localPort/remoteIP/remotePort, so you can't have two TCP
connections that use the same 4-uple. So, even if the connect is
non-blocking, it can't even get started until the previous one is
done.
S+E
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden