In the example of official doc,seems that we should accept connection one by one.This makes me confused,so I read the source code of sun.nio.ch.UnixAsynchronousServerSocketChannelImpl ,in the line 269 there is a comment check and set flag to prevent concurrent accepting,So could someone tell me why should prevent current accepting? Is this a OS's limit or there is no need to accept connection currently.Thanks in advance.
-
I'd assume it is to prevent creating multiple socket instances or streams when the conection request is received. So it would cause problems to accept concurently. See how the NIO is meant to be handled - there should be only a single Selector thread to accept connections, however you may have multiple threads to handle the data..gusto2– gusto22017-11-14 08:57:43 +00:00Commented Nov 14, 2017 at 8:57
Add a comment
|