I have build a simple application that opens a ServerSocket, and on connection, it connects itself to another server socket on a remote machine. To implement port forwarding
Take a look at tcpmon. Its purpose is to monitor tcp data, but it also forwards to a different host/port.
And here is some code for port forwarding taken from a book (it's not in English, so I'm pasting the code rather than giving a link to the book e-version):