📄 e177. creating a non-blocking server socket.txt
字号:
This example shows how to create a non-blocking server socket. A non-blocking server socket requires a server socket channel.
See also e179 Using a Selector to Manage Non-Blocking Server Sockets.
// Create a non-blocking server socket and check for connections
try {
// Create a non-blocking server socket channel on port 80
ServerSocketChannel ssChannel = ServerSocketChannel.open();
ssChannel.configureBlocking(false);
int port = 80;
ssChannel.socket().bind(new InetSocketAddress(port));
// See e178 Accepting a Connection on a ServerSocketChannel
// for an example of accepting a connection request
} catch (IOException e) {
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -