A VB6 class to allow a TCP/IP server to map ports through a UPnP NAT router without manual intervention and retrieve the router's external public IP address.
Queries and returns the external public address of the router's public (Internet facing) interface. Can add and remove port mappings for TCP and UDP ports. Uses the Windows UPnP Control Point interface instead of the sometimes more problematic NATUPnP library.
Packaged with a simple chat server and client to demonstrate basic use. PortMapper.cls contains comments documenting its properties, methods, and events.
Windows XP or later. Must have SSDP components ("Network Discovery") enabled and the Windows Firewall or other software firewall must allow UPnP traffic through.NAT router:
Must support some level of UPnP port mapping ("Virtual Servers" or "Forwarded Ports" defined via UPnP). UPnP must be enabled (may require reboot).
Unencumbered freeware. No guarantee of support. Use at your own risk. This software is offered AS IS.
PortMapper has been tested on Windows XP SP3, Vista SP2, and Windows 7 RC using a D-Link EBR-2310 wired router (Version B1 hardware, Version 2.01 firmware).
Working With PortMapper
Much more detail can be found by reading the comments in PortMapper.cls.
To add PortMapper to your VB6 project copy PortMapper.cls and PortMapperCBs.cls from the SimpleServer folder to your project folder, then use Project|Add file... to add each of these two modules to your Project.
To use the demo chat client and server compile each of the two programs, then run the server and click its Listen button, then run the client and fill in the server's external IP address and a "chat handle" name and click its Connect button.
Be sure to scroll down for the latest version!