Package net.i2p.i2ptunnel.socks
Class SocketWrapper
- java.lang.Object
-
- net.i2p.i2ptunnel.socks.SocketWrapper
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,I2PSocket
class SocketWrapper extends Object implements 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
Constructors Constructor Description SocketWrapper(Socket sock)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
SelectableChannel
getChannel()
Deprecated.InputStream
getInputStream()
As of 0.9.9 will throw an IOE if socket is closed.int
getLocalPort()
The local port.I2PSocketOptions
getOptions()
OutputStream
getOutputStream()
As of 0.9.9 will throw an IOE if socket is closed.Destination
getPeerDestination()
int
getPort()
The remote port.long
getReadTimeout()
How long we will wait blocked on a read() operation.Destination
getThisDestination()
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
setSocketErrorListener(I2PSocket.SocketErrorListener lsnr)
Deprecated, unimplemented, does nothing
-
-
-
Constructor Detail
-
SocketWrapper
public SocketWrapper(Socket sock)
-
-
Method Detail
-
getThisDestination
public Destination getThisDestination()
- Specified by:
getThisDestination
in interfaceI2PSocket
- Returns:
- the Destination of this side of the socket.
-
getPeerDestination
public Destination getPeerDestination()
- Specified by:
getPeerDestination
in interfaceI2PSocket
- Returns:
- the destination of the peer.
-
getInputStream
public InputStream getInputStream() throws IOException
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
public OutputStream getOutputStream() throws IOException
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 public SelectableChannel getChannel()
Deprecated.Description copied from interface:I2PSocket
Unimplemented, unlikely to ever be implemented.- Specified by:
getChannel
in interfaceI2PSocket
- Returns:
- null always
-
getOptions
public I2PSocketOptions getOptions()
- Specified by:
getOptions
in interfaceI2PSocket
- Returns:
- null always
-
setOptions
public void setOptions(I2PSocketOptions options)
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
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
reset
public void reset() throws IOException
Just calls close()- Specified by:
reset
in interfaceI2PSocket
- Throws:
IOException
- Since:
- 0.9.30
-
setSocketErrorListener
public void setSocketErrorListener(I2PSocket.SocketErrorListener lsnr)
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
-
-