java.lang.Object
org.miaixz.bus.socket.accord.UdpBootstrap
UDP服务启动类
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
ConstructorsConstructorDescriptionUdpBootstrap(Message<Request> message, Handler<Request> handler) 构造UdpBootstrap(Message<Request> message, Handler<Request> handler, Worker worker) 构造 -
Method Summary
Modifier and TypeMethodDescriptionopen()开启一个UDP通道,端口号随机open(int port) 开启一个UDP通道开启一个UDP通道final UdpBootstrapsetBufferPagePool(BufferPagePool bufferPool) 设置内存池 通过该方法设置的内存池,在AioServer执行shutdown时不会触发内存池的释放。final UdpBootstrapsetReadBufferSize(int size) 设置读缓存区大小final UdpBootstrapsetThreadNum(int num) 设置线程大小voidshutdown()
-
Constructor Details
-
UdpBootstrap
构造- Type Parameters:
Request- 当前请求- Parameters:
message- 消息处理handler- 拦截器worker- 工作者
-
UdpBootstrap
构造- Type Parameters:
Request- 当前请求- Parameters:
message- 消息处理handler- 拦截器
-
-
Method Details
-
open
开启一个UDP通道,端口号随机- Returns:
- UDP通道
- Throws:
IOException
-
open
开启一个UDP通道- Parameters:
port- 指定绑定端口号,为0则随机指定- Throws:
IOException
-
open
开启一个UDP通道- Parameters:
host- 绑定本机地址port- 指定绑定端口号,为0则随机指定- Throws:
IOException
-
shutdown
public void shutdown() -
setReadBufferSize
设置读缓存区大小- Parameters:
size- 单位:byte
-
setThreadNum
设置线程大小- Parameters:
num- 线程数
-
setBufferPagePool
设置内存池 通过该方法设置的内存池,在AioServer执行shutdown时不会触发内存池的释放。 该方法适用于多个AioServer、AioClient共享内存池的场景。 在启用内存池的情况下会有更好的性能表现- Parameters:
bufferPool- 内存池对象- Returns:
- 当前AioServer对象
-