On 24/09/2014 16:58, Kirk Shoop (MS OPEN TECH) wrote:
SIO_LOOPBACK_FAST_PATH must be set on the socket passed to accept.
The way I think about this is the socket instance passed to listen
represents the port while the socket instance passed to accept
represents a single TCP stream. SIO_LOOPBACK_FAST_PATH has no effect
when applied to a port, but does have an effect when applied to a TCP
stream.
Given that we are open to suggestions for a better organization of the
code to set SIO_LOOPBACK_FAST_PATH on the sockets passed to accept.
Taking ServerSocketChannel has an example then you are setting
SIO_LOOPBACK_FAST_PATH over and over on the same socket and it's not
clear to me that this is needed. My reading of the
SIO_LOOPBACK_FAST_PATH page is that it just needs to be set once on the
listener and the socket corresponding to each of the subsequently
accepted connections will use the fast path. Perhaps my reading is
incorrect and you mean that accept will reset the setting after it
accepts a connection?
The AsynchronouServerSocketChannel case is clearly a bit different as it
needs to create the SOCKET in advance before the connection is accepted
but in that case it will still create the SOCKET via Net.socket0.
One thing that isn't clear to me from the document is whether it is
possible to enable SIO_LOOPBACK_FAST_PATH before calling listen. If that
is allowed then I think you should be able to just set the option in
Net.c socket0 and it should work for all NIO usages.
-Alan