java.lang.Object
org.miaixz.bus.socket.plugin.AbstractPlugin<T>
org.miaixz.bus.socket.plugin.SocketOptionPlugin<T>
用于设置Socket Option的插件
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <V> VgetOption(SocketOption<V> socketOption) final <V> SocketOptionPlugin<T> setOption(SocketOption<V> socketOption, V value) 设置Socket的TCP参数配置。voidsetOption(AsynchronousSocketChannel channel) 往socket channel中设置option值。shouldAccept(AsynchronousSocketChannel channel) 监控已接收到的连接Methods inherited from class org.miaixz.bus.socket.plugin.AbstractPlugin
afterRead, afterWrite, beforeRead, beforeWrite, process, stateEvent, toHex, toHexString
-
Constructor Details
-
SocketOptionPlugin
public SocketOptionPlugin()
-
-
Method Details
-
shouldAccept
Description copied from interface:Monitor监控已接收到的连接- Specified by:
shouldAcceptin interfaceMonitor- Overrides:
shouldAcceptin classAbstractPlugin<T>- Parameters:
channel- 当前已经建立连接的通道对象- Returns:
- 非null:接受该连接,null:拒绝该连接
-
setOption
往socket channel中设置option值。 默认将通过setOption(SocketOption, Object)指定的配置值绑定到每一个Socket中。 如果有个性化的需求,可以重新实现本方法。- Parameters:
channel- 频道
-
setOption
设置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
-