If you have a software that requires port forwarding, you may want to implement UPnP to make things easy for your end users.
When I wanted to implement it, the first library I found was [MiniUPnP](http://miniupnp.free.fr/files/), sadly it doesn't have much documentation but a quick look at the header files and some examples on the internet I managed to make it work, here is how:
First the required include directives we need:
```c
#include <miniupnpc/miniupnpc.h>
#include <miniupnpc/upnpcommands.h>
#include <miniupnpc/upnperrors.h>
#include <stdio.h>
```
The first thing we need to do is discover the UPnP devices on the network, this is done using `upnpDiscover`:
Now the port is mapped, at this point you can open a socket bound to the internal port and external clients will be able to connect using the external port.