Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

upnp

UPnP implementation for FPC

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

upnp

UPnP implementation for FPC

Sample

pascal
UPnP := TUPnP.Create('0.0.0.0');
pascal
if UPnP.IsUPnPAvailable then
begin
  Writeln('UPnP device is available at ' + UPnP.ControlURL);
pascal
// Set a port mapping
if UPnP.SetPortMapping(UPnP.InternalIP, 8081, 8000, 'TCP') then // use own computer IP
pascal
// Delete a port mapping
if UPnP.DeletePortMapping(8000) then

Example output

pascal
UPnP is available.
pascal
Internal IP: 192.168.2.11
External IP: x.x.x.x
Status: Connected
Last error: ERROR_NONE
Uptime router: 23 days, 4 hours 41 minutes and 24 seoconds
pascal
SetPortMapping OK
Portmappings:
0 UDP 3332->192.168.2.21:3332 libminiupnpc 0 s
1 UDP 3344->192.168.2.21:4444 test 0 s
2 TCP 8000->192.168.2.11:8081  0 s
pascal
Check port. Press Enter to delete and terminate
pascal
DeletePortMapping OK
pascal
Portmappings:
0 UDP 3332->192.168.2.21:3332 libminiupnpc 0 s
1 UDP 3344->192.168.2.21:4444 test 0 s
pascal
We are done, press enter