Package net.i2p.i2ptunnel.socks
Class SocketWrapper
java.lang.Object
net.i2p.i2ptunnel.socks.SocketWrapper
- All Implemented Interfaces:
Closeable
,AutoCloseable
,I2PSocket
Wrapper around the Socket obtained from the Outproxy, which is a
wrapper around the Orchid Stream.
- Since:
- 0.9.27
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.i2p.client.streaming.I2PSocket
I2PSocket.SocketErrorListener
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Deprecated.As of 0.9.9 will throw an IOE if socket is closed.int
The local port.As of 0.9.9 will throw an IOE if socket is closed.int
getPort()
The remote port.long
How long we will wait blocked on a read() operation.boolean
isClosed()
void
reset()
Just calls close()void
setOptions
(I2PSocketOptions options) Does nothingvoid
setReadTimeout
(long ms) Define how long we will wait blocked on a read() operation (-1 will make the socket wait forever).void
Deprecated, unimplemented, does nothing
-
Constructor Details
-
SocketWrapper
-
-
Method Details
-
getThisDestination
- Specified by:
getThisDestination
in interfaceI2PSocket
- Returns:
- the Destination of this side of the socket.
-
getPeerDestination
- Specified by:
getPeerDestination
in interfaceI2PSocket
- Returns:
- the destination of the peer.
-
getInputStream
Description copied from interface:I2PSocket
As of 0.9.9 will throw an IOE if socket is closed. Prior to that would return null instead of throwing IOE.Note that operations on the returned stream may return an
IOException
whose cause as returned byThrowable.getCause()
is anI2PSocketException
. If so, the client may retrieve a status code viaI2PSocketException.getStatus()
to provide specific feedback to the user.- Specified by:
getInputStream
in interfaceI2PSocket
- Returns:
- an InputStream to read from the socket. Non-null since 0.9.9.
- Throws:
IOException
- on failure
-
getOutputStream
Description copied from interface:I2PSocket
As of 0.9.9 will throw an IOE if socket is closed. Prior to that would return null instead of throwing IOE.Note that operations on the returned stream may return an
IOException
whose cause as returned byThrowable.getCause()
is anI2PSocketException
. If so, the client may retrieve a status code viaI2PSocketException.getStatus()
to provide specific feedback to the user.- Specified by:
getOutputStream
in interfaceI2PSocket
- Returns:
- an OutputStream to write into the socket. Non-null since 0.9.9.
- Throws:
IOException
- on failure
-
getChannel
Deprecated.Description copied from interface:I2PSocket
Unimplemented, unlikely to ever be implemented.- Specified by:
getChannel
in interfaceI2PSocket
- Returns:
- null always
-
getOptions
- Specified by:
getOptions
in interfaceI2PSocket
- Returns:
- null always
-
setOptions
Does nothing- Specified by:
setOptions
in interfaceI2PSocket
- Parameters:
options
- I2PSocketOptions to set
-
getReadTimeout
public long getReadTimeout()Description copied from interface:I2PSocket
How long we will wait blocked on a read() operation. This is simply a helper to query the I2PSocketOptions- Specified by:
getReadTimeout
in interfaceI2PSocket
- Returns:
- milliseconds to wait, or -1 if we will wait indefinitely
-
setReadTimeout
public void setReadTimeout(long ms) Description copied from interface:I2PSocket
Define how long we will wait blocked on a read() operation (-1 will make the socket wait forever). This is simply a helper to adjust the I2PSocketOptions- Specified by:
setReadTimeout
in interfaceI2PSocket
- Parameters:
ms
- timeout in ms
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
reset
Just calls close()- Specified by:
reset
in interfaceI2PSocket
- Throws:
IOException
- Since:
- 0.9.30
-
isClosed
public boolean isClosed() -
setSocketErrorListener
Deprecated, unimplemented, does nothing- Specified by:
setSocketErrorListener
in interfaceI2PSocket
-
getPort
public int getPort()The remote port. -
getLocalPort
public int getLocalPort()The local port.- Specified by:
getLocalPort
in interfaceI2PSocket
- Returns:
- 0 always
-