// Accept the connection and make it non-blocking
SocketChannel socketChannel = serverSocketChannel.accept();
Socket socket = socketChannel.socket();
//socket.setSoTimeout(1000*10);//it will be timeout if idle more than 10s
//after testing, i found the parameter in socketchannel didnot work
//the following is what i google:
//you don't need a timeout,
//because SC's (SC means SocketChannel) do a non-blocking Connect, and send a message to the Selector with message type CONNECTED when that becomes the case

//in the protosocket, read method is a blocking invocation, so it need a "timeout" parameter ,in case some evil connection

 

相关文章:

  • 2021-07-25
  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2022-01-12
  • 2021-06-22
猜你喜欢
  • 2021-12-16
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-05
相关资源
相似解决方案