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
Define the configuration for streaming and verifying data on the socket.
Use I2PSocketManager.buildOptions() to get one of these.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intFields inherited from interface net.i2p.client.streaming.I2PSocketOptions
PROP_BUFFER_SIZE, PROP_CONNECT_TIMEOUT, PROP_READ_TIMEOUT, PROP_WRITE_TIMEOUT -
Constructor Summary
ConstructorsConstructorDescriptionSets max buffer size, connect timeout, read timeout, and write timeout from System properties.Sets max buffer size, connect timeout, read timeout, and write timeout from properties.Initializes from System properties then copies over all options. -
Method Summary
Modifier and TypeMethodDescriptionlongHow long we will wait for the ACK from a SYN, in milliseconds.static doublegetDouble(Properties opts, String name, double defaultVal) Not part of the API, not for external use.protected static intgetInt(Properties opts, String name, int defaultVal) intThe local port.intHow much data will we accept that hasn't been written out yet.intgetPort()The remote port.longWhat is the longest we'll block on the input stream while waiting for more data.longWhat is the longest we'll block on the output stream while waiting for the data to flush.protected voidinit(Properties opts) Sets max buffer size, connect timeout, read timeout, and write timeout from properties.voidsetConnectTimeout(long ms) Define how long we will wait for the ACK from a SYN, in milliseconds.voidsetLocalPort(int port) The local port.voidsetMaxBufferSize(int numBytes) How much data will we accept that hasn't been written out yet.voidsetPort(int port) The remote port.voidsetProperties(Properties opts) Sets max buffer size, connect timeout, read timeout, and write timeout from properties.voidsetReadTimeout(long ms) What is the longest we'll block on the input stream while waiting for more data.voidsetWriteTimeout(long ms) What is the longest we'll block on the output stream while waiting for the data to flush.
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE- See Also:
-
DEFAULT_READ_TIMEOUT
public static final int DEFAULT_READ_TIMEOUT- See Also:
-
DEFAULT_WRITE_TIMEOUT
public static final int DEFAULT_WRITE_TIMEOUT- See Also:
-
DEFAULT_CONNECT_TIMEOUT
public static final int DEFAULT_CONNECT_TIMEOUT- See Also:
-
-
Constructor Details
-
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
Initializes from System properties then copies over all options.- Parameters:
opts- may be null
-
I2PSocketOptionsImpl
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 Details
-
setProperties
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
Sets max buffer size, connect timeout, read timeout, and write timeout from properties. Does not set local port or remote port. -
getInt
-
getDouble
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:
getConnectTimeoutin 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:
setConnectTimeoutin 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:
getReadTimeoutin 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:
setReadTimeoutin 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:
getMaxBufferSizein 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:
setMaxBufferSizein 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:
getWriteTimeoutin 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:
setWriteTimeoutin 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:
getPortin 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:
setPortin interfaceI2PSocketOptions- Parameters:
port- 0 - 65535- Throws:
IllegalArgumentException- Since:
- 0.8.9
-
getLocalPort
public int getLocalPort()The local port.- Specified by:
getLocalPortin 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:
setLocalPortin interfaceI2PSocketOptions- Parameters:
port- 0 - 65535- Throws:
IllegalArgumentException- Since:
- 0.8.9
-