I have to build TCP proxy functionality. I am trying to use NIO classes. Generally this is what I want to do: 1. Source device tries to connect to the proxy port A 2. the proxy tries to connect the destination device on port B 3. if the proxy succeeds establishing a connection, then the proxy accepts the source connection otherwise rejects it.
The problem is in a fact that sch accepts connection before the code perfoms sch.accept();
In this moment the source device dumps data to the proxy even the destination connection has not been established. I wanted accept() to be delayed until it is programatically executed. How do I do this?