Usually you have one tcp port connected and several connections to them. At least there are usually more connections as connected ports. My thing is different: I want to bind a lot of ports and usually do not have (or at least very few) connections.
Therefore, I want to use NIO to receive incoming connections.
However, I need to transfer the accepted connections to the existing jsch ssh library. This requires IO sockets instead of NIO sockets, it generates one (or two) stream (s) for each connection. But it is perfect for me.
Now I thought the following lines would produce the same result:
Socket a = serverSocketChannel.accept().socket();
Socket b = serverSocketChannel.socket().accept();
SocketChannel channel = serverSocketChannel.accept();
channel.configureBlocking( true );
Socket c = channel.socket();
Socket d = serverSocket.accept();
However, the functions getInputStream()and getOutputStream()returned sockets seem different. Only if the socket was received using the last call, jsch can work with it. In the first three cases, he fails (and I'm sorry: I don't know why).
So is there a way to convert such a socket?
source
share