Package net.i2p.client.streaming.impl
Class I2PSocketOptionsImpl
- java.lang.Object
-
- net.i2p.client.streaming.impl.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.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_BUFFER_SIZE
static int
DEFAULT_CONNECT_TIMEOUT
static int
DEFAULT_READ_TIMEOUT
static int
DEFAULT_WRITE_TIMEOUT
-
Fields inherited from interface net.i2p.client.streaming.I2PSocketOptions
PROP_BUFFER_SIZE, PROP_CONNECT_TIMEOUT, PROP_READ_TIMEOUT, PROP_WRITE_TIMEOUT
-
-
Constructor Summary
Constructors Constructor Description I2PSocketOptionsImpl()
Sets max buffer size, connect timeout, read timeout, and write timeout from System properties.I2PSocketOptionsImpl(Properties opts)
Sets max buffer size, connect timeout, read timeout, and write timeout from properties.I2PSocketOptionsImpl(I2PSocketOptions opts)
Initializes from System properties then copies over all options.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getConnectTimeout()
How long we will wait for the ACK from a SYN, in milliseconds.static double
getDouble(Properties opts, String name, double defaultVal)
Not part of the API, not for external use.protected static int
getInt(Properties opts, String name, int defaultVal)
int
getLocalPort()
The local port.int
getMaxBufferSize()
How much data will we accept that hasn't been written out yet.int
getPort()
The remote port.long
getReadTimeout()
What is the longest we'll block on the input stream while waiting for more data.long
getWriteTimeout()
What is the longest we'll block on the output stream while waiting for the data to flush.protected void
init(Properties opts)
Sets max buffer size, connect timeout, read timeout, and write timeout from properties.void
setConnectTimeout(long ms)
Define how long we will wait for the ACK from a SYN, in milliseconds.void
setLocalPort(int port)
The local port.void
setMaxBufferSize(int numBytes)
How much data will we accept that hasn't been written out yet.void
setPort(int port)
The remote port.void
setProperties(Properties opts)
Sets max buffer size, connect timeout, read timeout, and write timeout from properties.void
setReadTimeout(long ms)
What is the longest we'll block on the input stream while waiting for more data.void
setWriteTimeout(long ms)
What is the longest we'll block on the output stream while waiting for the data to flush.
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_READ_TIMEOUT
public static final int DEFAULT_READ_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_WRITE_TIMEOUT
public static final int DEFAULT_WRITE_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_CONNECT_TIMEOUT
public static final int DEFAULT_CONNECT_TIMEOUT
- See Also:
- Constant Field Values
-
-
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 interfaceI2PSocketOptions
- 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 interfaceI2PSocketOptions
- 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 interfaceI2PSocketOptions
- 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 interfaceI2PSocketOptions
- 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 interfaceI2PSocketOptions
- 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 interfaceI2PSocketOptions
- 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 interfaceI2PSocketOptions
- 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 interfaceI2PSocketOptions
- 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 interfaceI2PSocketOptions
- Returns:
- Default I2PSession.PORT_UNSPECIFIED (0) or PORT_ANY (0)
- Since:
- 0.8.9
-
setPort
public void setPort(int port)
The remote port.- Specified by:
setPort
in interfaceI2PSocketOptions
- Parameters:
port
- 0 - 65535- Throws:
IllegalArgumentException
- Since:
- 0.8.9
-
getLocalPort
public int getLocalPort()
The local port.- Specified by:
getLocalPort
in interfaceI2PSocketOptions
- 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 interfaceI2PSocketOptions
- Parameters:
port
- 0 - 65535- Throws:
IllegalArgumentException
- Since:
- 0.8.9
-
-