Re: NIO
- From: Bjorn Borud <borud-news@xxxxxxxx>
- Date: 17 Jun 2005 01:50:26 +0200
["Remon van Vliet" <remon@xxxxxxxxxxxx>]
| > which will happen immediately the connection is complete, not much point
| > selecting for it really
|
| It's good practice to do writing once OP_WRITE is selected, that it
| happens immediately is true, but doesnt change the fact that it's
| bad style to assume it. But fair enough, it will work.
no, you don't generally want to waste time doing another select to
determine if the socket is writable, because it would constitute
fairly odd behavior if it *wasn't* writable when connect has
completed.
in fact, the way the underlying implementation on UNIX (using the
poll() or select() _system calls_) decides if the socket is done
connecting is to check if it is writable. OP_CONNECT seems to have
been an API design tradeoff made to hide this fact because it may
confuse people.
also, when you have a connected socket and you have a scenario where
it is plausible that the data you have written has been sent, so the
OS can accept more data on that connection, you always try to write
the data first and *if* you have some data left that didn't get
written, you enqueue that and let the select() loop take care of
pushing it through the connection once the socket becomes writable
again.
-Bjørn
.
- References:
- Prev by Date: Re: Help with searching numbers
- Next by Date: Re: Equivalent functionality to Thread.stop()?
- Previous by thread: Re: NIO
- Next by thread: Re: NIO
- Index(es):
Relevant Pages
|