Hi
Usually you have a single bound tcp port and several connections on these. At least there are usually more connections as bound ports. My case is different: I want to bind a lot of ports and usually have no (or at least very few) connections.
So I want to use NIO to accept the incoming connections.
However, I need to pass the accepted connections to the existing jsch ssh library. That requires IO sockets instead of NIO sockets, it spawns one (or two) thread(s) per connection. But that's fine for me.
Now, I thought that the following lines would deliver the very same result:
Socket a = serverSocketChannel.accept().socket();
Socket b = serverSocketChannel.socket().accep();
SocketChannel channel = serverSocketChannel.accpet();
channel.configureBlocking( true );
Socket c = channel.socket();
Socket d = serverSocket.accept();
However the getInputStream()
and getOutputStream()
functions of the returned sockets seem to work different. Only if the socket was accepted using the last call, jsch can work with it. In the first three cases, it fails (and I am sorry: I don't know why).
So is there a way to convert such a socket?
Regards, Steffen