If you want to communicate through a NAT router, you can configure port migration using UPnP from your application. So, for example, torrent programs can communicate without having to configure port transfer.
In .net, you can use the NATUPnP 1.0 Type Library (NATUPNP.DLL) COM component that is included with Windows (starting with Windows, XP).
Add link to the lump

Get a list of all existing port mappings
NATUPNPLib.UPnPNATClass upnpnat = new NATUPNPLib.UPnPNATClass(); NATUPNPLib.IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection;
Iterate through all mappings
foreach(NATUPNPLib.IStaticPortMapping portMapping in mappings) {
Add new port mapping
// Here an example of opening up TCP Port 80 to forward to a specific Computer on the Private Network mappings.Add(80, "TCP", 80, "192.168.1.100", true, "Local Web Server"); // Here an example of forwarding the UDP traffic of Internet Port 80 to Port 8080 on a Computer on the Private Network mappings.Add(80, "UDP", 8080, "192.168.1.100", true, "Local Web Server");
Remove Port Mapping
// Remove TCP forwarding for Port 80 mappings.Remove(80, "TCP"); // Remove UDP forwarding for Port 8080 mappings.Remove(8080, "UDP");
Source: http: //pietschsoft.com / ...
source share