View previous topic :: View next topic |
Author |
Message |
Nocs
Joined: 07 Mar 2016 Posts: 3
|
Posted: Mon Mar 07, 2016 11:28 pm Post subject: Include miniupnp in c++ (kick start for newbies) |
|
|
Hello tuxfamily,
First of all great work !
Since i am a newbie in c++ and therefore learned much in a small period of time i am trying to create dynamically through my app a port forwarding so my app which has UDP and TCP connections can send and recieve finally messages via internet through a router at specific port.
On my searches around the net i droped on your miniupnp which as far as i read around seems well promising and you do well cause with windows libraries port forwarding seems like trying to open a wall with your bare fingers.
So to get strait to the point, i downloaded your latest minipnpc.tar and compiled the solution for MS VS and the upnpc-static.exe runs ok as first sight on my system but i would like to know how and what to import from your libraries and headers into my UDP and TCP application and get started using your miniupnp to make two things :
1. finally open a desired port on my router and close it whenever i like it or find the appropiate port on my router to communicate from and with via internet
2. send and recieve UDP or TCP messages into this port via internet
These are my basic kick starts to check this and congruts you but i dont know what to implement on my c++ app from your libraries and headers yet.
Could you kinldy point me according to my needs ? |
|
Back to top |
|
 |
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1593
|
Posted: Tue Mar 08, 2016 12:15 pm Post subject: |
|
|
well if you compiled for MSVC you should have noticed it is producing a library.
See upnpc.c to see how to use the library.
Code: |
devlist = upnpDiscover(2000, multicastif, minissdpdpath,
localport, ipv6, ttl, &error);
i = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));
UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
eport, iport, iaddr, description,
proto, 0, leaseDuration);
|
see documentation of each function in miniupnpc.h / upnpcommands.h _________________ Main miniUPnP author.
https://miniupnp.tuxfamily.org/ |
|
Back to top |
|
 |
Nocs
Joined: 07 Mar 2016 Posts: 3
|
Posted: Tue Mar 08, 2016 1:40 pm Post subject: |
|
|
Thank you for your response.
Yes it creates a lib file, i will use this lib in my project app
I dont use any headers on my app ? only the lib ? |
|
Back to top |
|
 |
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1593
|
Posted: Tue Mar 08, 2016 3:51 pm Post subject: |
|
|
Quote: | see documentation of each function in miniupnpc.h / upnpcommands.h |
You won't ask us make your work, will you ? _________________ Main miniUPnP author.
https://miniupnp.tuxfamily.org/ |
|
Back to top |
|
 |
Nocs
Joined: 07 Mar 2016 Posts: 3
|
Posted: Tue Mar 08, 2016 4:45 pm Post subject: |
|
|
As i said ita kickstart for newbies but i will try to implement it as your header says.
Thank you for your response |
|
Back to top |
|
 |
|