Module swim.io
Package swim.io

Class TcpSettings

java.lang.Object
swim.io.TcpSettings
All Implemented Interfaces:
Debug

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

    Fields
    Modifier and Type
    Field
    Description
    protected final boolean
     
    protected final boolean
     
    protected final int
     
    protected final int
     
    protected final int
     
    protected final int
     
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    boolean
    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.
    <T> Output<T>
    debug(Output<T> output)
    Writes a developer readable, debug-formatted string representation of this object to output.
    boolean
    equals(Object other)
     
    Returns the structural Form of TcpSettings.
    int
     
    final boolean
    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(boolean keepAlive)
    Returns a copy of these TcpSettings configured with the given keepAlive value for the SO_KEEPALIVE socket option.
    final boolean
    Returns true if TCP should be configured with the TCP_NODELAY socket option to disable Nagle's algorithm.
    noDelay(boolean noDelay)
    Returns a copy of these TcpSettings configured with the given noDelay value for the TCP_NODELAY socket option.
    final int
    Returns the size in bytes of the per-socket userspace buffers into which data is received.
    readBufferSize(int readBufferSize)
    Returns a copy of these TcpSettings configured with the given readBufferSize for per-socket userspace read buffers.
    final int
    Returns the value of the SO_RCVBUF socket option with which TCP should be configured to control the size of receive buffers.
    receiveBufferSize(int receiveBufferSize)
    Returns a copy of these TcpSettings configured with the given receiveBufferSize value for the SO_RCVBUF socket option.
    final int
    Returns the value of the SO_SNDBUF socket option with which TCP should be configured to control the size of send buffers.
    sendBufferSize(int sendBufferSize)
    Returns a copy of these TcpSettings configured with the given sendBufferSize value for the SO_SNDBUF socket option.
    Returns the default TcpSettings instance.
     
    Returns a structural Value representing these TcpSettings.
    final int
    Returns the size in bytes of the per-socket userspace buffers from which data is sent.
    writeBufferSize(int writeBufferSize)
    Returns a copy of these TcpSettings configured with the given writeBufferSize for per-socket userspace write buffers.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • 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 Details

    • TcpSettings

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

    • 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.
    • configure

      public void configure(Socket socket) throws SocketException
      Configures the socket with these TcpSettings.
      Throws:
      SocketException
    • 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.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

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

      public <T> Output<T> debug(Output<T> 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
      Returns:
      the continuation of the output.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • standard

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

      @Kind public static Form<TcpSettings> form()
      Returns the structural Form of TcpSettings.