public class I2PSocketManagerFull extends Object implements I2PSocketManager
I2PSocketManager.DisconnectListener| Modifier and Type | Field and Description |
|---|---|
(package private) static PcapWriter |
pcapWriter |
(package private) static String |
PROP_PCAP |
| Constructor and Description |
|---|
I2PSocketManagerFull(I2PAppContext context,
I2PSession session,
Properties opts,
String name,
IncomingConnectionFilter connectionFilter)
This is what I2PSocketManagerFactory.createManager() returns.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDisconnectListener(I2PSocketManager.DisconnectListener lsnr) |
I2PSession |
addSubsession(InputStream privateKeyStream,
Properties opts)
For a server, you must call connect() on the returned object.
|
I2PSocketOptions |
buildOptions()
Create a copy of the current options, to be used in a setDefaultOptions() call.
|
I2PSocketOptions |
buildOptions(Properties opts)
Create a modified copy of the current options, to be used in a setDefaultOptions() call.
|
I2PSocket |
connect(Destination peer)
Create a new connected socket.
|
I2PSocket |
connect(Destination peer,
I2PSocketOptions options)
Create a new connected socket.
|
Socket |
connectToSocket(Destination peer)
Like connect() but returns a real Socket, and throws only IOE,
for easier porting of apps.
|
Socket |
connectToSocket(Destination peer,
int timeout)
Like connect() but returns a real Socket, and throws only IOE,
for easier porting of apps.
|
void |
destroySocketManager()
Destroy the socket manager, freeing all the associated resources.
|
long |
getAcceptTimeout() |
ConnectionManager |
getConnectionManager() |
I2PSocketOptions |
getDefaultOptions()
Current options, not a copy, setters may be used to make changes.
|
String |
getName()
For logging / diagnostics only
|
I2PServerSocket |
getServerSocket()
Returns non-null socket.
|
I2PSession |
getSession() |
ServerSocket |
getStandardServerSocket()
Like getServerSocket but returns a real ServerSocket for easier porting of apps.
|
List<I2PSession> |
getSubsessions() |
boolean |
isDestroyed()
Has the socket manager been destroyed?
|
Set<I2PSocket> |
listSockets()
Retrieve a set of currently connected I2PSockets, either initiated locally or remotely.
|
boolean |
ping(Destination peer,
int localPort,
int remotePort,
long timeoutMs)
Ping the specified peer, returning true if they replied to the ping within
the timeout specified, false otherwise.
|
byte[] |
ping(Destination peer,
int localPort,
int remotePort,
long timeoutMs,
byte[] payload)
Ping the specified peer, returning true if they replied to the ping within
the timeout specified, false otherwise.
|
boolean |
ping(Destination peer,
long timeoutMs)
Ping the specified peer, returning true if they replied to the ping within
the timeout specified, false otherwise.
|
I2PSocket |
receiveSocket()
The accept() call.
|
void |
removeDisconnectListener(I2PSocketManager.DisconnectListener lsnr) |
void |
removeSubsession(I2PSession session)
Remove the subsession
|
void |
setAcceptTimeout(long ms)
How long should we wait for the client to .accept() a socket before
sending back a NACK/Close?
|
void |
setDefaultOptions(I2PSocketOptions options)
Update the options on a running socket manager.
|
void |
setName(String name)
For logging / diagnostics only
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinitstatic PcapWriter pcapWriter
static final String PROP_PCAP
public I2PSocketManagerFull(I2PAppContext context, I2PSession session, Properties opts, String name, IncomingConnectionFilter connectionFilter)
context - non-nullsession - non-nullopts - may be nullname - non-nullpublic void addDisconnectListener(I2PSocketManager.DisconnectListener lsnr)
addDisconnectListener in interface I2PSocketManagerpublic I2PSession addSubsession(InputStream privateKeyStream, Properties opts) throws I2PSessionException
addSubsession in interface I2PSocketManagerprivateKeyStream - null for transient, if non-null must have same encryption keys as primary session
and different signing keysopts - subsession options if any, may be nullI2PSessionExceptionpublic I2PSocketOptions buildOptions()
buildOptions in interface I2PSocketManagerpublic I2PSocketOptions buildOptions(Properties opts)
buildOptions in interface I2PSocketManageropts - The new options, may be nullpublic I2PSocket connect(Destination peer) throws I2PException, NoRouteToHostException
connect in interface I2PSocketManagerpeer - Destination to connect toNoRouteToHostException - if the peer is not found or not reachableI2PException - if there is some other I2P-related problempublic I2PSocket connect(Destination peer, I2PSocketOptions options) throws I2PException, NoRouteToHostException
connect in interface I2PSocketManagerpeer - Destination to connect tooptions - I2P socket options to be used for connecting, may be nullNoRouteToHostException - if the peer is not found or not reachableI2PException - if there is some other I2P-related problempublic Socket connectToSocket(Destination peer) throws IOException
connectToSocket in interface I2PSocketManagerIOExceptionpublic Socket connectToSocket(Destination peer, int timeout) throws IOException
connectToSocket in interface I2PSocketManagertimeout - ms if > 0, forces blocking (disables connectDelay)IOExceptionpublic void destroySocketManager()
destroySocketManager in interface I2PSocketManagerpublic long getAcceptTimeout()
getAcceptTimeout in interface I2PSocketManagerpublic ConnectionManager getConnectionManager()
public I2PSocketOptions getDefaultOptions()
getDefaultOptions in interface I2PSocketManagerpublic String getName()
getName in interface I2PSocketManagerpublic I2PServerSocket getServerSocket()
getServerSocket in interface I2PSocketManagerpublic I2PSession getSession()
getSession in interface I2PSocketManagerpublic ServerSocket getStandardServerSocket() throws IOException
getStandardServerSocket in interface I2PSocketManagerIOExceptionpublic List<I2PSession> getSubsessions()
getSubsessions in interface I2PSocketManagerpublic boolean isDestroyed()
isDestroyed in interface I2PSocketManagerpublic Set<I2PSocket> listSockets()
listSockets in interface I2PSocketManagerpublic boolean ping(Destination peer, int localPort, int remotePort, long timeoutMs)
ping in interface I2PSocketManagerpeer - Destination to pinglocalPort - 0 - 65535remotePort - 0 - 65535timeoutMs - timeout in ms, greater than zeroIllegalArgumentExceptionpublic byte[] ping(Destination peer, int localPort, int remotePort, long timeoutMs, byte[] payload)
ping in interface I2PSocketManagerpeer - Destination to pinglocalPort - 0 - 65535remotePort - 0 - 65535timeoutMs - timeout in ms, greater than zeropayload - to include in the pingIllegalArgumentExceptionpublic boolean ping(Destination peer, long timeoutMs)
ping in interface I2PSocketManagerpeer - timeoutMs - timeout in ms, greater than zeroIllegalArgumentExceptionpublic I2PSocket receiveSocket() throws I2PException, ConnectException, SocketTimeoutException
I2PException - if session is closedRouterRestartException - (extends I2PException) if the router is apparently restarting, since 0.9.34ConnectException - (since 0.9.17; I2PServerSocket interface always declared it)SocketTimeoutException - if a timeout was previously set with setSoTimeout and the timeout has been reached.public void removeDisconnectListener(I2PSocketManager.DisconnectListener lsnr)
removeDisconnectListener in interface I2PSocketManagerpublic void removeSubsession(I2PSession session)
removeSubsession in interface I2PSocketManagerpublic void setAcceptTimeout(long ms)
setAcceptTimeout in interface I2PSocketManagerms - milliseconds to wait, maximumpublic void setDefaultOptions(I2PSocketOptions options)
setDefaultOptions in interface I2PSocketManageroptions - as created from a call to buildOptions(properties), non-nullpublic void setName(String name)
setName in interface I2PSocketManager