Re: TCP connect in Non Blocking Mode
- From: David Schwartz <davids@xxxxxxxxxxxxx>
- Date: Fri, 25 Apr 2008 15:34:11 -0700 (PDT)
On Apr 25, 1:59 pm, Rainer Temme <Rainer_Te...@xxxxxxxxxxxxxxxxxxxxxx>
wrote:
He's trying to connect. Checking for readability doesn't make sense
unless he has nothing else to do until the other side sends him any
data.
Acutally, select() poll() do NOT check for readablity but for
the ability to call read() without being blocked in the call.
Since the connection is refused by the RST, read() should
return iommediately with result -1 and errno set to ECONNREFUSED.
And select() should indicate that a read() can be called without
being blocked.
But a 'write' can be called without being blocked too, so checking for
readability is at best redundant. If the connection succeeds, it will
be writable but not readable, so checking for 'read'ability won't
detect connection success.
This is why the typical pattern is to check an asynchronous 'connect'
attempt only for writability.
DS
.
- Follow-Ups:
- Re: TCP connect in Non Blocking Mode
- From: Rainer Temme
- Re: TCP connect in Non Blocking Mode
- References:
- TCP connect in Non Blocking Mode
- From: Prabhu
- Re: TCP connect in Non Blocking Mode
- From: Rainer Temme
- Re: TCP connect in Non Blocking Mode
- From: David Schwartz
- Re: TCP connect in Non Blocking Mode
- From: Rainer Temme
- TCP connect in Non Blocking Mode
- Prev by Date: Re: TCP connect in Non Blocking Mode
- Next by Date: Re: /dev/urandom too slow on my system
- Previous by thread: Re: TCP connect in Non Blocking Mode
- Next by thread: Re: TCP connect in Non Blocking Mode
- Index(es):
Relevant Pages
|