Re: TCP connect in Non Blocking Mode
- From: Rainer Weikusat <rweikusat@xxxxxxxxxxx>
- Date: Mon, 28 Apr 2008 11:56:46 +0200
Alex Fraser <me@xxxxxxxxxxx> writes:
Rainer Weikusat wrote:
Rainer Temme <Rainer_Temme@xxxxxxxxxxxxxxxxxxxxxx> writes:
David Schwartz wrote:[...]
The to-be-expected behaviour is actually standardized:If the connection succeeds, it will be writable but not readable,Whether a socket will become readable after connect
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.
also depends on the protocol used ... SMTP and FTP
are exaples of protocols where the serverside
will send an immediate message to the client
after successful connection.
Anyhow, my suggestion was to set the bit in the readset
as well as in the writeset. You might regard this as redundant
but (as even you had to admit) it will not harm.
If the connection cannot be established immediately and
O_NONBLOCK is set for the file descriptor for the socket,
connect() shall fail and set errno to [EINPROGRESS], but the
connection request shall not be aborted, and the connection
shall be established asynchronously. Subsequent calls to
connect() for the same socket, before the connection is
established, shall fail and set errno to [EALREADY].
When the connection has been established
asynchronously,
select() and poll() shall indicate that the file descriptor
for the socket is ready for writing.
http://www.opengroup.org/onlinepubs/009695399/functions/connect.html
This does not specify the case where a blocking connect() would have
failed, which is the issue at hand.
It specifies the case I was refering to, which happened to be the one
the discussion had moved to at this point, cf
,----
| If the connection succeeds, it will be writable but not
| readable, so checking for 'read'ability won't detect
| connection success.
`----
and
,----
| Whether a socket will become readable after connect
| also depends on the protocol used ... SMTP and FTP
`----
Additionally, 'cargo cult programming'
http://catb.org/jargon/html/C/cargo-cult-programming.html
does harm. It causes the technical damage of keeping the machine busy
with doing useless instead of useful things. [...]
I agree, but the only reason I can think of for considering Rainer
Temme's suggestion is such is not reading the thread.
Comparing
,----
| Anyhow, my suggestion was to set the bit in the readset
| as well as in the writeset. You might regard this as redundant
| but (as even you had to admit) it will not harm.
`----
with
,----
| A style of programming dominated by ritual inclusion of code
| or program structures that serve no real purpose. A cargo cult
| programmer will usually explain the extra code as a way of
| working around some bug encountered in the past,
`----
I consider the first text to be a near-perfect example of what is
described in the second. If it is or it isn't is completely
independent of anything related to me, and your ad hominem is
therefore besides the point.
.
- Follow-Ups:
- Re: TCP connect in Non Blocking Mode
- From: Alex Fraser
- Re: TCP connect in Non Blocking Mode
- From: David Schwartz
- 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
- Re: TCP connect in Non Blocking Mode
- From: David Schwartz
- Re: TCP connect in Non Blocking Mode
- From: Rainer Temme
- Re: TCP connect in Non Blocking Mode
- From: Rainer Weikusat
- Re: TCP connect in Non Blocking Mode
- From: Alex Fraser
- TCP connect in Non Blocking Mode
- Prev by Date: Re: How to suppress 'Entering/Leaving ...' messages while running make?
- Next by Date: Re: http server lib?
- Previous by thread: Re: TCP connect in Non Blocking Mode
- Next by thread: Re: TCP connect in Non Blocking Mode
- Index(es):
Relevant Pages
|