Class TcpUtils


  • public class TcpUtils
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static interface  TcpUtils.OptionSetter<S>  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private TcpUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method 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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TcpUtils

        private TcpUtils()
    • Method Detail

      • tuneTcpSocket

        public static void tuneTcpSocket​(java.nio.channels.SocketChannel channel)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • setTcpReceiveBuffer

        public static boolean setTcpReceiveBuffer​(java.nio.channels.Channel channel,
                                                  int rcvbuf)
      • setTcpSendBuffer

        public static boolean setTcpSendBuffer​(java.nio.channels.Channel channel,
                                               int sndbuf)
      • setIpTypeOfService

        public static boolean setIpTypeOfService​(java.nio.channels.Channel channel,
                                                 int tos)
      • setReuseAddress

        public static boolean setReuseAddress​(java.nio.channels.Channel channel,
                                              boolean reuse)
      • tuneTcpKeepalives

        public static void tuneTcpKeepalives​(java.nio.channels.SocketChannel channel,
                                             int tcpKeepAlive,
                                             int tcpKeepAliveCnt,
                                             int tcpKeepAliveIdle,
                                             int tcpKeepAliveIntvl)
      • setOption

        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
        Parameters:
        channel -
        setter -
      • unblockSocket

        public static void unblockSocket​(java.nio.channels.SelectableChannel... channels)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • enableIpv4Mapping

        public static void enableIpv4Mapping​(java.nio.channels.SelectableChannel channel)
      • getPeerIpAddress

        public static Address getPeerIpAddress​(java.nio.channels.SocketChannel channel)