This tool is a simple tcp traffic forwarder: all incoming data on the given port will be forwarded to the given IP/port. Most firewall can do this but this tool runs in userland and anyway the purpose of this code is mostly to give an example of how to use select() FD_SET() and friends functions.
You can for example have a box with 2 NICs, one with a public IP and another one on a private network, another box on the private network with the 192.168.0.2 IP and with a web server listening on port 80: you start the tcpforwarder on the public box with
tcpforwarder 184.108.40.206 8080 192.168.0.2 80this would allow you to connect from outside on the public IP:8080 port to the internal web server. The first IP is the listening interface, in case you have more than one.
Click here to grab the source code.