A few years ago, I needed to debug a network program. Specifically, I needed to capture all the data being sent and received by a network application to find a problem. Normally one would run a packet capture utility (a program that captures everything being sent over a local area network for later review), but that wasn't an option at the time.
I searched online for a cheap (read "free") solution to my problem. If necessary, I could have written something to do the job, but I didn't want to if I didn't need to. I came across the source code for a little program called PortForward. It was a simple program to accept connections from one machine and forward them to another. The only thing it didn't do that I needed was log the network activity.
So I took the code and adapted it to my needs. The code is not perfect, but it did what I needed. Maybe you'll find it useful.
Note: I received permission to post it on my site, but never got around to it at the time. I just came across it again and decided to finally do it. Unfortunately, the original site doesn't seem to be online any more.
Go Top