TcpGateway - A listen-listen TCP gateway in C#

TcpGateway is a listen-listen TCP gateway (Gender Changer, TCP relay) for Windows. It may be used to bypass NAT routers, e.g. for VNC, or for testing purposes.

Download and Sources

Gateway classes source:  TcpGateway.cs
Windows Service source: TcpGatewayService.cs
Test programs: TestTcpGateway.cs, TcpStressTest.cs
Download full package:
Source code repository: browse / Subversion URL

How to use the Tcp Gateway with the Java VNC Viewer Applet

TcpGateway may be used with the VNC viewer applet. I recommend to use the RealVNC freeware version of vncviewer.jar. (The current UltraVNC version of the applet does not work with TcpGateway, because it opens two TCP connections, one before the password prompt and one after the password prompt).

The following HTML code may be used to place the applet on a HTML page:

<script src=""></script>
{archive:"vncviewer.jar", code:"vncviewer/VNCViewer.class", width:"250", Height:"400"},

The port number for the applet (1001) has to be one of the ports configured in TcpGatewayService.xml. The VNC server has to do a callback (add new client) to the other port using a host name like

Author: Christian d'Heureuse (,