public class AioServer extends Object implements Closeable
Modifier and Type | Field and Description |
---|---|
protected SocketConfig |
config |
protected IoAction<ByteBuffer> |
ioAction |
Constructor and Description |
---|
AioServer(InetSocketAddress address,
SocketConfig config)
构造
|
AioServer(int port)
构造
|
Modifier and Type | Method and Description |
---|---|
AioServer |
accept()
处理接入的客户端
|
void |
close()
关闭服务
|
AsynchronousServerSocketChannel |
getChannel()
|
IoAction<ByteBuffer> |
getIoAction()
获取IO处理器
|
AioServer |
init(InetSocketAddress address)
初始化
|
boolean |
isOpen()
服务是否开启状态
|
AioServer |
setIoAction(IoAction<ByteBuffer> ioAction)
设置IO处理器,单例存在
|
<T> AioServer |
setOption(SocketOption<T> name,
T value)
设置 Socket 的 Option 选项
选项见: StandardSocketOptions |
void |
start(boolean sync)
开始监听
|
protected IoAction<ByteBuffer> ioAction
protected final SocketConfig config
public AioServer(int port)
port
- 端口public AioServer(InetSocketAddress address, SocketConfig config)
address
- 地址config
- SocketConfig
配置项public AioServer init(InetSocketAddress address)
address
- 地址和端口public void start(boolean sync)
sync
- 是否阻塞public <T> AioServer setOption(SocketOption<T> name, T value) throws IOException
StandardSocketOptions
T
- 选项泛型name
- SocketOption
枚举value
- SocketOption参数IOException
- IO异常public IoAction<ByteBuffer> getIoAction()
IoAction
public AioServer setIoAction(IoAction<ByteBuffer> ioAction)
ioAction
- IoAction
public AsynchronousServerSocketChannel getChannel()
AsynchronousServerSocketChannel
public AioServer accept()
public boolean isOpen()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2021. All rights reserved.