First, a little background to explain the motivation: I\'m working on a very simple select()-based TCP \"mirror proxy\", that allows two firewalled clients to talk to each
If your proxy must be a general purpose proxy for any protocol, then you should handle also those clients which sends data and immediately calls close
after the send (one way data transfer only).
So if client A sends a data and closes the connection before the connection is opened to B, don't worry, just forward the data to B normally (when connection to B is opened).
There is no need to implement special handling for this scenario.
Your proxy will detect the closed connection when:
read
returns zero after connection to B is opened and all pending data from A is read. or