dreadslicer
Joined: 23 Jan 2013 Posts: 1
|
Posted: Wed Jan 23, 2013 9:13 pm Post subject: natpmp automatically selecting ports? |
|
|
Code: | #include <iostream>
#include <natpmp.h>
using namespace std;
void redirect(uint16_t privateport, uint16_t publicport)
{
int r;
natpmp_t natpmp;
natpmpresp_t response;
initnatpmp(&natpmp,0,NATPMP_RESPTYPE_UDPPORTMAPPING);
sendnewportmappingrequest(&natpmp, NATPMP_PROTOCOL_TCP, privateport, publicport, 3600);
do {
fd_set fds;
struct timeval timeout;
FD_ZERO(&fds);
FD_SET(natpmp.s, &fds);
getnatpmprequesttimeout(&natpmp, &timeout);
select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
r = readnatpmpresponseorretry(&natpmp, &response);
} while(r==NATPMP_TRYAGAIN);
cout << "mapped public port "<<response.pnu.newportmapping.mappedpublicport<<
" to localport "<<response.pnu.newportmapping.privateport<<" liftime "<<
response.pnu.newportmapping.lifetime<<"\n";
closenatpmp(&natpmp);
}
int main (){
redirect(32000,32000);
} |
This code does work, however, it doesn't set the port to 32000:32000... it sets it:
Quote: | mapped public port 20701 to localport 22404 liftime 32539 |
I'm trying to make a game system and I need these ports open.... I'm going to assume that if it gets the port open, I would THEN start the port listener using a UDP server w/ these special ports? |
|