public abstract class NioServer extends Object implements Closeable
| 构造器和说明 |
|---|
NioServer(int port)
构造
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close() |
NioServer |
init(InetSocketAddress address)
初始化
|
void |
listen()
开始监听
|
protected abstract void |
read(SocketChannel socketChannel)
处理读事件
当收到读取准备就绪的信号后,回调此方法,用户可读取从客户端传世来的消息 |
protected abstract void |
write(SocketChannel socketChannel)
实现写逻辑
当收到写出准备就绪的信号后,回调此方法,用户可向客户端发送消息 |
public NioServer init(InetSocketAddress address)
address - 地址和端口public void listen()
public void close()
throws IOException
close 在接口中 Closeableclose 在接口中 AutoCloseableIOExceptionprotected abstract void read(SocketChannel socketChannel)
socketChannel - SocketChannelprotected abstract void write(SocketChannel socketChannel)
socketChannel - SocketChannelCopyright © 2020. All rights reserved.