Class I2PSocketOptionsImpl

  • All Implemented Interfaces:
    I2PSocketOptions
    Direct Known Subclasses:
    ConnectionOptions

    class I2PSocketOptionsImpl
    extends Object
    implements I2PSocketOptions
    Define the configuration for streaming and verifying data on the socket. Use I2PSocketManager.buildOptions() to get one of these.
    • Constructor Detail

      • I2PSocketOptionsImpl

        public I2PSocketOptionsImpl()
        Sets max buffer size, connect timeout, read timeout, and write timeout from System properties. Does not set local port or remote port.
      • I2PSocketOptionsImpl

        public I2PSocketOptionsImpl​(I2PSocketOptions opts)
        Initializes from System properties then copies over all options.
        Parameters:
        opts - may be null
      • I2PSocketOptionsImpl

        public I2PSocketOptionsImpl​(Properties opts)
        Sets max buffer size, connect timeout, read timeout, and write timeout from properties. Does not set local port or remote port. As of 0.9.19, defaults in opts are honored.
        Parameters:
        opts - may be null
    • Method Detail

      • setProperties

        public void setProperties​(Properties opts)
        Sets max buffer size, connect timeout, read timeout, and write timeout from properties. Does not set local port or remote port. As of 0.9.19, defaults in opts are honored.
        Parameters:
        opts - may be null
      • init

        protected void init​(Properties opts)
        Sets max buffer size, connect timeout, read timeout, and write timeout from properties. Does not set local port or remote port.
      • getInt

        protected static int getInt​(Properties opts,
                                    String name,
                                    int defaultVal)
      • getDouble

        public static double getDouble​(Properties opts,
                                       String name,
                                       double defaultVal)
        Not part of the API, not for external use.
      • getConnectTimeout

        public long getConnectTimeout()
        How long we will wait for the ACK from a SYN, in milliseconds. Default 60 seconds. Max of 2 minutes enforced in Connection.java, and it also interprets <= 0 as default.
        Specified by:
        getConnectTimeout in interface I2PSocketOptions
        Returns:
        milliseconds to wait, or -1 if we will wait indefinitely
      • setConnectTimeout

        public void setConnectTimeout​(long ms)
        Define how long we will wait for the ACK from a SYN, in milliseconds. Default 60 seconds. Max of 2 minutes enforced in Connection.java, and it also interprets <= 0 as default.
        Specified by:
        setConnectTimeout in interface I2PSocketOptions
        Parameters:
        ms - timeout in ms
      • getReadTimeout

        public long getReadTimeout()
        What is the longest we'll block on the input stream while waiting for more data. If this value is exceeded, the read() throws SocketTimeoutException as of 0.9.36. Prior to that, the read() returned -1 or 0. WARNING: Default -1 (unlimited), which is probably not what you want.
        Specified by:
        getReadTimeout in interface I2PSocketOptions
        Returns:
        timeout in ms, 0 for nonblocking, -1 for forever
      • setReadTimeout

        public void setReadTimeout​(long ms)
        What is the longest we'll block on the input stream while waiting for more data. If this value is exceeded, the read() throws SocketTimeoutException as of 0.9.36. Prior to that, the read() returned -1 or 0. WARNING: Default -1 (unlimited), which is probably not what you want.
        Specified by:
        setReadTimeout in interface I2PSocketOptions
        Parameters:
        ms - timeout in ms, 0 for nonblocking, -1 for forever
      • getMaxBufferSize

        public int getMaxBufferSize()
        How much data will we accept that hasn't been written out yet. After this amount has been exceeded, subsequent .write calls will block until either some data is removed or the connection is closed. If this is less than or equal to zero, there is no limit (warning: can eat ram) Default 64 KB
        Specified by:
        getMaxBufferSize in interface I2PSocketOptions
        Returns:
        buffer size limit, in bytes
      • setMaxBufferSize

        public void setMaxBufferSize​(int numBytes)
        How much data will we accept that hasn't been written out yet. After this amount has been exceeded, subsequent .write calls will block until either some data is removed or the connection is closed. If this is less than or equal to zero, there is no limit (warning: can eat ram) Default 64 KB
        Specified by:
        setMaxBufferSize in interface I2PSocketOptions
        Parameters:
        numBytes - How much data will we accept that hasn't been written out yet.
      • getWriteTimeout

        public long getWriteTimeout()
        What is the longest we'll block on the output stream while waiting for the data to flush. If this value is exceeded, the write() throws InterruptedIOException. If this is less than or equal to zero, there is no timeout. Default -1 (unlimited)
        Specified by:
        getWriteTimeout in interface I2PSocketOptions
        Returns:
        wait time to block on the output stream while waiting for the data to flush.
      • setWriteTimeout

        public void setWriteTimeout​(long ms)
        What is the longest we'll block on the output stream while waiting for the data to flush. If this value is exceeded, the write() throws InterruptedIOException. If this is less than or equal to zero, there is no timeout. Default -1 (unlimited)
        Specified by:
        setWriteTimeout in interface I2PSocketOptions
        Parameters:
        ms - wait time to block on the output stream while waiting for the data to flush.
      • getPort

        public int getPort()
        The remote port.
        Specified by:
        getPort in interface I2PSocketOptions
        Returns:
        Default I2PSession.PORT_UNSPECIFIED (0) or PORT_ANY (0)
        Since:
        0.8.9
      • getLocalPort

        public int getLocalPort()
        The local port.
        Specified by:
        getLocalPort in interface I2PSocketOptions
        Returns:
        Default I2PSession.PORT_UNSPECIFIED (0) or PORT_ANY (0)
        Since:
        0.8.9
      • setLocalPort

        public void setLocalPort​(int port)
        The local port. Zero (default) means you will receive traffic on all ports. Nonzero means you will get traffic ONLY for that port, use with care, as most applications do not specify a remote port.
        Specified by:
        setLocalPort in interface I2PSocketOptions
        Parameters:
        port - 0 - 65535
        Throws:
        IllegalArgumentException
        Since:
        0.8.9