Back to product page

NewUPNPMapping event


Fires when new UPnP port mapping was created.

Syntax

  • C#
  • C++
  • VB.NET
delegate void devP2P.NewUPNPMappingEvent(IntPtr Handle, string ExtAddress, string IntAddress, int TCPPort, int UDPPort);
The NewUPNPMapping(Handle,ExtAddress,IntAddress,TCPPort,UDPPort) syntax has these parts:
HandleReference to the devP2P instance.
ExtAddressIP address on UPNP device.
IntAddressOur IP address.
TCPPortTCP port on the UPNP device that forwards back to us.
UDPPortUDP port on the UPNP device that forwards back to us.

void NewUPNPMapping(CP2P *p2p, char *ExtAddress, char *IntAddress, int TCPPort, int UDPPort);
The NewUPNPMapping(p2p,ExtAddress,IntAddress,TCPPort,UDPPort) syntax has these parts:
p2pPointer to devP2P instance that fired the event.
ExtAddressPoints to buffer with external IP address on UPNP device.
IntAddressPoints to buffer with our IP address.
TCPPortTCP port on the UPNP device that forwards back to us.
UDPPortUDP port on the UPNP device that forwards back to us.

Delegate Sub P2P_NewUPNPMappingEvent(ByVal Handle As IntPtr, ByVal ExtAddress As String, ByVal IntAddress As String, ByVal TCPPort As Integer, ByVal UDPPort As Integer)
The NewUPNPMapping(Handle,ExtAddress,IntAddress,TCPPort,UDPPort) syntax has these parts:
HandleReference to the devP2P instance.
ExtAddressIP address on UPNP device.
IntAddressPoints to buffer with our IP address.
TCPPortTCP port on the UPNP device that forwards back to us.
UDPPortUDP port on the UPNP device that forwards back to us.

Remarks

NewUPnPMapping event is fired when devP2P maps external port on UPnP device (usually firewall or router device) so that remote peer can connect to that device to establish connection with your devP2P instance. You do not need to make any special setup on your that device - as long as UPnP service is provided, devP2P will know how to use it.

You should, however, call UPNPInit in your code to enable UPnP.

To use this event, you should implement function by yourself in the code (based on function declaration), and set devP2P.Events.NewUPNPMapping structure member to point to your function.

Code sample

  • C++

Platforms

Windows
Mac OSX
Linux
BSD