This Linux program is a proxy server that joins together pairs of incoming TCP connections. It listens simultaneously on two ports (supply and demand) and connects any new client on the demand port with a client waiting on the supply port.
Usage: ./tcpcoupler [options] supply-port demand-port [driver-port]
Options:
--brief Print brief information (default).
-h --help Display this usage information.
-p --period Driver refresh period in seconds (30).
-t --timeout Connection idle timeout in seconds (60).
--verbose Print verbose information.
-v --version Show version information.
If the driver port command line parameter is provided, then the number of connections waiting on the demand port is sent to all clients connected to the driver port.
Below is given an example setup that makes use of the driver-port parameter. Let's say a tcpcoupler instance is running on the remotehost domain, having port 5000 for its suppy-port, port 6000 for its demand-port and port 7000 for its driver-port. We now wish to provide some TCP service running on localhost port 4000 from the mentioned remote host. To do so, we utilize the netcat, xargs and tcpnipple tools.
nc remotehost 7000 | \
xargs -I {} -P 0 ./tcpnipple -c {} localhost 4000 remotehost 5000
Every time a new connection is made to remotehost:6000, the number of waiting connections is sent via the driver-port to the netcat instance. The latter will forward that number to xargs which in turn spawns tcpnipple, connecting the server on localhost:4000 to the server on remotehost:5000.