SocketRelay is a project mainly written in C++ and C, it's free.
A simple socket relay program
The source code here is taken from VisIt. Some modifications have been made.