ServerSocketChannel
ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
serverSocketChannel.socket().bind(new InetSocketAddress(9999));
while(true){
SocketChannel socketChannel =
serverSocketChannel.accept();
//do something with socketChannel...
}打开 ServerSocketChannel
ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();关闭 ServerSocketChannel
监听新进来的连接
非阻塞模式
Last updated