public class TcpUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static interface |
TcpUtils.OptionSetter<S> |
Modifier | Constructor and Description |
---|---|
private |
TcpUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
enableIpv4Mapping(java.nio.channels.SelectableChannel channel) |
static Address |
getPeerIpAddress(java.nio.channels.SocketChannel channel) |
static boolean |
setIpTypeOfService(java.nio.channels.Channel channel,
int tos) |
private static void |
setOption(java.nio.channels.Channel channel,
TcpUtils.OptionSetter<java.net.Socket> setter)
A single setter method, used when the option doesn't apply to a
ServerSocket |
private static void |
setOption(java.nio.channels.Channel channel,
TcpUtils.OptionSetter<java.net.Socket> setter,
TcpUtils.OptionSetter<java.net.ServerSocket> serverSetter) |
static boolean |
setReuseAddress(java.nio.channels.Channel channel,
boolean reuse) |
static boolean |
setTcpReceiveBuffer(java.nio.channels.Channel channel,
int rcvbuf) |
static boolean |
setTcpSendBuffer(java.nio.channels.Channel channel,
int sndbuf) |
static void |
tuneTcpKeepalives(java.nio.channels.SocketChannel channel,
int tcpKeepAlive,
int tcpKeepAliveCnt,
int tcpKeepAliveIdle,
int tcpKeepAliveIntvl) |
static void |
tuneTcpSocket(java.nio.channels.SocketChannel channel) |
static void |
unblockSocket(java.nio.channels.SelectableChannel... channels) |
public static void tuneTcpSocket(java.nio.channels.SocketChannel channel) throws java.io.IOException
java.io.IOException
public static boolean setTcpReceiveBuffer(java.nio.channels.Channel channel, int rcvbuf)
public static boolean setTcpSendBuffer(java.nio.channels.Channel channel, int sndbuf)
public static boolean setIpTypeOfService(java.nio.channels.Channel channel, int tos)
public static boolean setReuseAddress(java.nio.channels.Channel channel, boolean reuse)
public static void tuneTcpKeepalives(java.nio.channels.SocketChannel channel, int tcpKeepAlive, int tcpKeepAliveCnt, int tcpKeepAliveIdle, int tcpKeepAliveIntvl)
private static void setOption(java.nio.channels.Channel channel, TcpUtils.OptionSetter<java.net.Socket> setter)
ServerSocket
channel
- setter
- private static void setOption(java.nio.channels.Channel channel, TcpUtils.OptionSetter<java.net.Socket> setter, TcpUtils.OptionSetter<java.net.ServerSocket> serverSetter)
public static void unblockSocket(java.nio.channels.SelectableChannel... channels) throws java.io.IOException
java.io.IOException
public static void enableIpv4Mapping(java.nio.channels.SelectableChannel channel)
public static Address getPeerIpAddress(java.nio.channels.SocketChannel channel)