• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: O_NONBLOCK & connect() not blocking
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >O_NONBLOCK & connect() not blocking (From: Mark Thomas <email@hidden>)

  • Prev by Date: O_NONBLOCK & connect() not blocking
  • Next by Date: Re: setting the DF bit on a UDP BSD socket in OS X
  • Previous by thread: O_NONBLOCK & connect() not blocking
  • Next by thread: Looking for pointers to 3G/UMTS info
  • Index(es):
    • Date
    • Thread