Module bus.socket

Class UdpBootstrap

java.lang.Object
org.miaixz.bus.socket.accord.UdpBootstrap

public class UdpBootstrap extends Object
UDP服务启动类
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • UdpBootstrap

      public UdpBootstrap(Message<Request> message, Handler<Request> handler, Worker worker)
      构造
      Type Parameters:
      Request - 当前请求
      Parameters:
      message - 消息处理
      handler - 拦截器
      worker - 工作者
    • UdpBootstrap

      public UdpBootstrap(Message<Request> message, Handler<Request> handler)
      构造
      Type Parameters:
      Request - 当前请求
      Parameters:
      message - 消息处理
      handler - 拦截器
  • Method Details

    • open

      public UdpChannel open() throws IOException
      开启一个UDP通道,端口号随机
      Returns:
      UDP通道
      Throws:
      IOException
    • open

      public UdpChannel open(int port) throws IOException
      开启一个UDP通道
      Parameters:
      port - 指定绑定端口号,为0则随机指定
      Throws:
      IOException
    • open

      public UdpChannel open(String host, int port) throws IOException
      开启一个UDP通道
      Parameters:
      host - 绑定本机地址
      port - 指定绑定端口号,为0则随机指定
      Throws:
      IOException
    • shutdown

      public void shutdown()
    • setReadBufferSize

      public final UdpBootstrap setReadBufferSize(int size)
      设置读缓存区大小
      Parameters:
      size - 单位:byte
    • setThreadNum

      public final UdpBootstrap setThreadNum(int num)
      设置线程大小
      Parameters:
      num - 线程数
    • setBufferPagePool

      public final UdpBootstrap setBufferPagePool(BufferPagePool bufferPool)
      设置内存池 通过该方法设置的内存池,在AioServer执行shutdown时不会触发内存池的释放。 该方法适用于多个AioServer、AioClient共享内存池的场景。 在启用内存池的情况下会有更好的性能表现
      Parameters:
      bufferPool - 内存池对象
      Returns:
      当前AioServer对象