- All Known Implementing Classes:
I2PServerSocketFull
public interface I2PServerSocket
Streaming server socket returned by
I2PSocketManager.getServerSocket(). Defines how to listen for streaming peer connections. Note that this is not a standard Java ServerSocket, if you need one of those, use I2PSocketManager.getStandardServerSocket() instead.
Method Summary
All MethodsModifier and TypeMethodDescriptionaccept()Waits for the next socket connecting.voidclose()Closes the socket.Access the manager which is coordinating the server socket.longAccept timeout for incoming connections, in ms.voidsetSoTimeout(long x) Accept timeout for incoming connections, in ms.
Method Details
close
Closes the socket.- Throws:
I2PException- if the socket cannot be closed, usually because the underlying I2PSession is already gone
accept
Waits for the next socket connecting. If a remote user tried to make a connection and the local application wasn't .accept()ing new connections, they should get refused (if .accept() doesnt occur in some small period). Unlike a regular ServerSocket, a connection left unaccepted is answered with a streaming RESET and accept() reports the failure by throwing instead of returning null.- Returns:
- a connected I2PSocket, never null
- Throws:
I2PException- if there is a problem with reading a new socket from the data available (e.g. the I2PSession is closed); this may be an I2PSessionException which extends I2PExceptionRouterRestartException- (extends I2PException) if the router is apparently restartingConnectException- if the I2PServerSocket is closed, or if interrupted.SocketTimeoutException- if a timeout was previously set with setSoTimeout and the timeout has been reached.
setSoTimeout
void setSoTimeout(long x) Accept timeout for incoming connections, in ms.- Parameters:
x- timeout in ms
getSoTimeout
long getSoTimeout()Accept timeout for incoming connections, in ms.- Returns:
- timeout in ms
getManager
I2PSocketManager getManager()Access the manager which is coordinating the server socket.- Returns:
- I2PSocketManager