Re: NIO



["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
.



Relevant Pages

  • Re: NIO
    ... >> non-blocking, which means that it will return from your .writeright ... >> 1) establish a connection using a non-blocking socket connect ... > This is generally pointless unless you want to timeout the connection ... > selecting for it really ...
    (comp.lang.java.programmer)
  • [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #3]
    ... These patches together supply secure client-side RxRPC connectivity as a Linux ... kernel socket family. ... presentation side is left to the client. ... Each connection goes to a particular "service". ...
    (Linux-Kernel)
  • [PATCH 0/5] [RFC] AF_RXRPC socket family implementation
    ... These patches together supply secure client-side RxRPC connectivity as a Linux ... Make it possible for the client socket to be used to go to more than one ... Each connection goes to a particular "service". ...
    (Linux-Kernel)
  • [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
    ... These patches together supply secure client-side RxRPC connectivity as a Linux ... Make it possible for the client socket to be used to go to more than one ... Each connection goes to a particular "service". ...
    (Linux-Kernel)
  • Re: Socket Exception
    ... In this case the server most likely rejected your ... connection. ... Each command is a new socket connection that is opened and closed ... /// Required designer variable. ...
    (microsoft.public.win32.programmer.networks)