Module swim.io
Package swim.io

Class TcpSettings

  • All Implemented Interfaces:
    Debug

    public class TcpSettings
    extends Object
    implements Debug
    TCP configuration parameters.
    • Constructor Summary

      Constructors 
      Constructor Description
      TcpSettings​(boolean keepAlive, boolean noDelay, int receiveBufferSize, int sendBufferSize, int readBufferSize, int writeBufferSize)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canEqual​(Object other)
      Returns true if these TcpSettings can possibly equal some other object.
      void configure​(Socket socket)
      Configures the socket with these TcpSettings.
      protected TcpSettings copy​(boolean keepAlive, boolean noDelay, int receiveBufferSize, int sendBufferSize, int readBufferSize, int writeBufferSize)
      Returns a new TcpSettings instance with the given options.
      void debug​(Output<?> output)
      Writes a developer readable, debug-formatted string representation of this object to output.
      boolean equals​(Object other)  
      static Form<TcpSettings> form()
      Returns the structural Form of TcpSettings.
      int hashCode()  
      boolean keepAlive()
      Returns true if TCP should be configured with the SO_KEEPALIVE socket option to send keepalive probes to prevent idle connections from timing out.
      TcpSettings keepAlive​(boolean keepAlive)
      Returns a copy of these TcpSettings configured with the given keepAlive value for the SO_KEEPALIVE socket option.
      boolean noDelay()
      Returns true if TCP should be configured with the TCP_NODELAY socket option to disable Nagle's algorithm.
      TcpSettings noDelay​(boolean noDelay)
      Returns a copy of these TcpSettings configured with the given noDelay value for the TCP_NODELAY socket option.
      int readBufferSize()
      Returns the size in bytes of the per-socket userspace buffers into which data is received.
      TcpSettings readBufferSize​(int readBufferSize)
      Returns a copy of these TcpSettings configured with the given readBufferSize for per-socket userspace read buffers.
      int receiveBufferSize()
      Returns the value of the SO_RCVBUF socket option with which TCP should be configured to control the size of receive buffers.
      TcpSettings receiveBufferSize​(int receiveBufferSize)
      Returns a copy of these TcpSettings configured with the given receiveBufferSize value for the SO_RCVBUF socket option.
      int sendBufferSize()
      Returns the value of the SO_SNDBUF socket option with which TCP should be configured to control the size of send buffers.
      TcpSettings sendBufferSize​(int sendBufferSize)
      Returns a copy of these TcpSettings configured with the given sendBufferSize value for the SO_SNDBUF socket option.
      static TcpSettings standard()
      Returns the default TcpSettings instance.
      String toString()  
      Value toValue()
      Returns a structural Value representing these TcpSettings.
      int writeBufferSize()
      Returns the size in bytes of the per-socket userspace buffers from which data is sent.
      TcpSettings writeBufferSize​(int writeBufferSize)
      Returns a copy of these TcpSettings configured with the given writeBufferSize for per-socket userspace write buffers.
    • Field Detail

      • keepAlive

        protected final boolean keepAlive
      • noDelay

        protected final boolean noDelay
      • receiveBufferSize

        protected final int receiveBufferSize
      • sendBufferSize

        protected final int sendBufferSize
      • readBufferSize

        protected final int readBufferSize
      • writeBufferSize

        protected final int writeBufferSize
    • Constructor Detail

      • TcpSettings

        public TcpSettings​(boolean keepAlive,
                           boolean noDelay,
                           int receiveBufferSize,
                           int sendBufferSize,
                           int readBufferSize,
                           int writeBufferSize)
    • Method Detail

      • keepAlive

        public final boolean keepAlive()
        Returns true if TCP should be configured with the SO_KEEPALIVE socket option to send keepalive probes to prevent idle connections from timing out.
      • keepAlive

        public TcpSettings keepAlive​(boolean keepAlive)
        Returns a copy of these TcpSettings configured with the given keepAlive value for the SO_KEEPALIVE socket option.
      • noDelay

        public final boolean noDelay()
        Returns true if TCP should be configured with the TCP_NODELAY socket option to disable Nagle's algorithm.
      • noDelay

        public TcpSettings noDelay​(boolean noDelay)
        Returns a copy of these TcpSettings configured with the given noDelay value for the TCP_NODELAY socket option.
      • receiveBufferSize

        public final int receiveBufferSize()
        Returns the value of the SO_RCVBUF socket option with which TCP should be configured to control the size of receive buffers.
      • receiveBufferSize

        public TcpSettings receiveBufferSize​(int receiveBufferSize)
        Returns a copy of these TcpSettings configured with the given receiveBufferSize value for the SO_RCVBUF socket option.
      • sendBufferSize

        public final int sendBufferSize()
        Returns the value of the SO_SNDBUF socket option with which TCP should be configured to control the size of send buffers.
      • sendBufferSize

        public TcpSettings sendBufferSize​(int sendBufferSize)
        Returns a copy of these TcpSettings configured with the given sendBufferSize value for the SO_SNDBUF socket option.
      • readBufferSize

        public final int readBufferSize()
        Returns the size in bytes of the per-socket userspace buffers into which data is received.
      • readBufferSize

        public TcpSettings readBufferSize​(int readBufferSize)
        Returns a copy of these TcpSettings configured with the given readBufferSize for per-socket userspace read buffers.
      • writeBufferSize

        public final int writeBufferSize()
        Returns the size in bytes of the per-socket userspace buffers from which data is sent.
      • writeBufferSize

        public TcpSettings writeBufferSize​(int writeBufferSize)
        Returns a copy of these TcpSettings configured with the given writeBufferSize for per-socket userspace write buffers.
      • copy

        protected TcpSettings copy​(boolean keepAlive,
                                   boolean noDelay,
                                   int receiveBufferSize,
                                   int sendBufferSize,
                                   int readBufferSize,
                                   int writeBufferSize)
        Returns a new TcpSettings instance with the given options. Subclasses may override this method to ensure the proper class is instantiated when updating settings.
      • toValue

        public Value toValue()
        Returns a structural Value representing these TcpSettings.
      • canEqual

        public boolean canEqual​(Object other)
        Returns true if these TcpSettings can possibly equal some other object.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • debug

        public void debug​(Output<?> output)
        Description copied from interface: Debug
        Writes a developer readable, debug-formatted string representation of this object to output.
        Specified by:
        debug in interface Debug
      • standard

        public static TcpSettings standard()
        Returns the default TcpSettings instance.