public class AioQuickServer<T> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected org.aoju.bus.socket.origin.TcpReadHandler<T> |
aioReadCompletionHandler
读回调事件处理
|
protected org.aoju.bus.socket.origin.TcpWriteHandler<T> |
aioWriteCompletionHandler
写回调事件处理
|
protected org.aoju.bus.core.io.BufferPool |
bufferPool |
protected org.aoju.bus.socket.origin.ServerConfig<T> |
config
Server端服务配置
|
| Constructor and Description |
|---|
AioQuickServer(int port,
Protocol<T> protocol,
Message<T> messageProcessor)
设置服务端启动必要参数配置
|
AioQuickServer(String host,
int port,
Protocol<T> protocol,
Message<T> messageProcessor) |
| Modifier and Type | Method and Description |
|---|---|
AioQuickServer<T> |
setBannerEnabled(boolean bannerEnabled)
是否启用控制台Banner打印
|
<V> AioQuickServer<T> |
setOption(SocketOption<V> socketOption,
V value)
设置Socket的TCP参数配置
|
AioQuickServer<T> |
setReadBufferSize(int size)
设置读缓存区大小
|
AioQuickServer<T> |
setThreadNum(int threadNum)
设置服务工作线程数,设置数值必须大于等于2
|
AioQuickServer<T> |
setWriteQueueCapacity(int writeQueueCapacity)
设置write缓冲区容量
|
void |
shutdown()
停止服务端
|
void |
start()
启动Server端的AIO服务
|
protected void |
start0(org.aoju.bus.socket.origin.Function<AsynchronousSocketChannel,org.aoju.bus.socket.origin.TcpAioSession<T>> aioSessionFunction)
内部启动逻辑
|
protected org.aoju.bus.socket.origin.ServerConfig<T> config
调用AioQuickServer的各setXX()方法,都是为了设置config的各配置项
protected org.aoju.bus.core.io.BufferPool bufferPool
protected org.aoju.bus.socket.origin.TcpReadHandler<T> aioReadCompletionHandler
protected org.aoju.bus.socket.origin.TcpWriteHandler<T> aioWriteCompletionHandler
public AioQuickServer(int port,
Protocol<T> protocol,
Message<T> messageProcessor)
port - 绑定服务端口号protocol - 协议编解码messageProcessor - 消息处理器public void start()
throws IOException
IOException - 异常protected final void start0(org.aoju.bus.socket.origin.Function<AsynchronousSocketChannel,org.aoju.bus.socket.origin.TcpAioSession<T>> aioSessionFunction) throws IOException
aioSessionFunction - 会话信息IOException - 异常public final void shutdown()
public final AioQuickServer<T> setReadBufferSize(int size)
size - 单位:bytepublic final AioQuickServer<T> setBannerEnabled(boolean bannerEnabled)
bannerEnabled - true:启用,false:禁用public final <V> AioQuickServer<T> setOption(SocketOption<V> socketOption, V value)
AIO客户端的有效可选范围为: 2. StandardSocketOptions.SO_RCVBUF 4. StandardSocketOptions.SO_REUSEADDR
V - 对象socketOption - 配置项value - 配置值public final AioQuickServer<T> setWriteQueueCapacity(int writeQueueCapacity)
writeQueueCapacity - 缓冲区大小public final AioQuickServer<T> setThreadNum(int threadNum)
threadNum - 线程数Copyright © 2020. All rights reserved.