java.lang.Object
org.miaixz.bus.socket.accord.AioServer
AIO服务端
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription禁用低代码模式final AioServersetBacklog(int backlog) 设置 backlog 大小setBufferPagePool(BufferPagePool bufferPool) 设置读写内存池。setBufferPagePool(BufferPagePool readBufferPool, BufferPagePool writeBufferPool) 设置读写内存池。<V> AioServersetOption(SocketOption<V> socketOption, V value) 设置Socket的TCP参数配置。setReadBufferSize(int size) 设置读缓存区大小setThreadNum(int threadNum) 设置服务工作线程数,设置数值必须大于等于2setWriteBuffer(int bufferSize, int bufferCapacity) 设置输出缓冲区容量voidshutdown()停止服务端voidstart()启动Server端的AIO服务voidstart(AsynchronousChannelGroup asynchronousChannelGroup) 内部启动逻辑
-
Constructor Details
-
AioServer
设置服务端启动必要参数配置- Parameters:
port- 绑定服务端口号message- 协议编解码handler- 消息处理器
-
AioServer
- Parameters:
host- 绑定服务端Host地址port- 绑定服务端口号message- 协议编解码handler- 消息处理器
-
-
Method Details
-
start
启动Server端的AIO服务- Throws:
IOException- IO异常
-
start
内部启动逻辑- Throws:
IOException- IO异常
-
shutdown
public void shutdown()停止服务端 -
setReadBufferSize
设置读缓存区大小- Parameters:
size- 单位:byte- Returns:
- this
-
setOption
设置Socket的TCP参数配置。AIO客户端的有效可选范围为:
2. StandardSocketOptions.SO_RCVBUF
4. StandardSocketOptions.SO_REUSEADDR
- Type Parameters:
V- 配置项类型- Parameters:
socketOption- 配置项value- 配置值- Returns:
- this
-
setThreadNum
设置服务工作线程数,设置数值必须大于等于2- Parameters:
threadNum- 线程数- Returns:
- this
-
setWriteBuffer
设置输出缓冲区容量- Parameters:
bufferSize- 单个内存块大小bufferCapacity- 内存块数量上限- Returns:
- this
-
setBacklog
设置 backlog 大小- Parameters:
backlog- backlog大小- Returns:
- this
-
setBufferPagePool
设置读写内存池。 该方法适用于多个AioQuickServer、AioQuickClient共享内存池的场景, 以获得更好的性能表现- Parameters:
bufferPool- 内存池对象- Returns:
- this
-
setBufferPagePool
设置读写内存池。 该方法适用于多个AioQuickServer、AioQuickClient共享内存池的场景, 以获得更好的性能表现- Parameters:
readBufferPool- 读内存池对象writeBufferPool- 写内存池对象- Returns:
- this
-
disableLowMemory
禁用低代码模式- Returns:
- this
-