I2PSocket should provide a method to return a standard Socket Adapter
We need a way to convert I2P Sockets to standard java.net.Socket objects.
In the Mesh Project we have code that accepts an I2P client socket and then examines the local port. If the local port is 80 the I2PSocket must be converted to a java.net.Socket and then dispatched to the HTTP server. If the port is anything else (eg 79, the finger port) the I2PSocket should be dispatched to an I2P Service. Eg we would like to write code like:
final I2PSocket remoteClientSocket = serverSocket.accept();
if (remoteClientSocket.getLocalPort() == HTTP_PORT)
httpServer.onClientConnected(remoteClientSocket.asStandardSocket());
else if (remoteClientSocket.getLocalPort() == FINGER_PORT)
fingerService.onClientConnected(remoteClientSocket);
Right now there is no way to convert an I2PSocket to a java.net.Socket. There is a class net.i2p.client.streaming.impl.StandardSocket that can adapt an I2PSocket to java.net.Socket but it is package private and inaccessible.
Workaround: Create a copy of impl.StandardSocket. It mostly seems to work though it differs in some ways because we don't have access to ConnectOptions.