Module bus.socket

Class SocketOptionPlugin<T>

java.lang.Object
org.miaixz.bus.socket.plugin.AbstractPlugin<T>
org.miaixz.bus.socket.plugin.SocketOptionPlugin<T>
All Implemented Interfaces:
Monitor, Plugin<T>

public class SocketOptionPlugin<T> extends AbstractPlugin<T>
用于设置Socket Option的插件
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • SocketOptionPlugin

      public SocketOptionPlugin()
  • Method Details

    • shouldAccept

      public final AsynchronousSocketChannel shouldAccept(AsynchronousSocketChannel channel)
      Description copied from interface: Monitor
      监控已接收到的连接
      Specified by:
      shouldAccept in interface Monitor
      Overrides:
      shouldAccept in class AbstractPlugin<T>
      Parameters:
      channel - 当前已经建立连接的通道对象
      Returns:
      非null:接受该连接,null:拒绝该连接
    • setOption

      public void setOption(AsynchronousSocketChannel channel)
      往socket channel中设置option值。 默认将通过setOption(SocketOption, Object)指定的配置值绑定到每一个Socket中。 如果有个性化的需求,可以重新实现本方法。
      Parameters:
      channel - 频道
    • setOption

      public final <V> SocketOptionPlugin<T> setOption(SocketOption<V> socketOption, V value)
      设置Socket的TCP参数配置。

      AIO客户端的有效可选范围为: 1. StandardSocketOptions.SO_SNDBUF 2. StandardSocketOptions.SO_RCVBUF 3. StandardSocketOptions.SO_KEEPALIVE 4. StandardSocketOptions.SO_REUSEADDR 5. StandardSocketOptions.TCP_NODELAY

      Type Parameters:
      V - 泛型
      Parameters:
      socketOption - 配置项
      value - 配置值
      Returns:
      the object
    • getOption

      public final <V> V getOption(SocketOption<V> socketOption)