I'm writing a new application that is going to accept read data from one TCP/IP socket and reflect it to a second TCP/IP connection. My problem is that the application on the receive side needs to act as both a client (request connection) and server (listen for connection requests). The same will be true on the send side of my application. I have no idea if the distant applications are going to be TCP/IP clients or servers so I need to be able to support both on my end.

Does anybody have ideas or code examples on how I can address this problem?

Thanks

Jim.