Class SocketOptions

  • All Implemented Interfaces:
    AutoCloseable

    public final class SocketOptions
    extends CrtResource
    This class wraps the aws_socket_options from aws-c-io to provide access to TCP/UDP socket configuration in the AWS Common Runtime.
    • Field Detail

      • connectTimeoutMs

        public int connectTimeoutMs
        Sets the number of milliseconds before a connection will be considered timed out
      • keepAliveIntervalSecs

        public int keepAliveIntervalSecs
        Sets the number of seconds between TCP keepalive packets being sent to the peer 0 disables keepalive
      • keepAliveTimeoutSecs

        public int keepAliveTimeoutSecs
        Sets the number of seconds to wait for a keepalive response before considering the connection timed out 0 disables keepalive
      • keepAliveMaxFailedProbes

        public int keepAliveMaxFailedProbes
        Sets the number of keep alive probes allowed to fail before the connection is considered lost. If zero, OS defaults are used. On Windows, this option is meaningless until Windows 10 1703.
      • keepAlive

        public boolean keepAlive
        If true, enables periodic transmits of keepalive messages for detecting a disconnected peer.
    • Constructor Detail

      • SocketOptions

        public SocketOptions()
        Creates a new set of socket options
    • Method Detail

      • setTcpKeepAlive

        public void setTcpKeepAlive​(int keepAliveTimeoutSecs,
                                    int keepAliveIntervalSecs)
        Enables TCP keepalive.
        Parameters:
        keepAliveTimeoutSecs - Sets the number of seconds to wait for a keepalive response before considering the connection timed out. 0 disables keepalive.
        keepAliveIntervalSecs - Sets the number of seconds between TCP keepalive packets being sent to the peer. 0 disables keepalive.
      • setTcpKeepAlive

        public void setTcpKeepAlive​(int keepAliveTimeoutSecs,
                                    int keepAliveIntervalSecs,
                                    int keepAliveMaxFailedProbes)
        Enables TCP keepalive.
        Parameters:
        keepAliveTimeoutSecs - Sets the number of seconds to wait for a keepalive response before considering the connection timed out. 0 disables keepalive.
        keepAliveIntervalSecs - Sets the number of seconds between TCP keepalive packets being sent to the peer. 0 disables keepalive.
        keepAliveMaxFailedProbes - Sets the number of keep alive probes allowed to fail before the connection is considered lost. If zero, OS defaults are used. On Windows, this option is meaningless until Windows 10 1703.
      • getNativeHandle

        public long getNativeHandle()
        Description copied from class: CrtResource
        returns the native handle associated with this CRTResource.
        Overrides:
        getNativeHandle in class CrtResource
        Returns:
        native address
      • canReleaseReferencesImmediately

        protected boolean canReleaseReferencesImmediately()
        Determines whether a resource releases its dependencies at the same time the native handle is released or if it waits. Resources that wait are responsible for calling releaseReferences() manually.
        Specified by:
        canReleaseReferencesImmediately in class CrtResource
        Returns:
        true if this resource releases synchronously, false if this resource performs async shutdown
      • releaseNativeHandle

        protected void releaseNativeHandle()
        Frees the native resources for this set of socket options
        Specified by:
        releaseNativeHandle in class CrtResource