1

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.

1
  • 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.. Commented Nov 14, 2017 at 8:57

1 Answer 1

1

You are conflating concurrency with asynchronicity. When you accept a connection via async I/O you should immediately schedule another asynchronous accept().

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.