Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions natpmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ NATPMP_LIBSPEC int initnatpmp(natpmp_t * p, int forcegw, in_addr_t forcedgw)
return NATPMP_ERR_INVALIDARGS;
memset(p, 0, sizeof(natpmp_t));
p->s = socket(PF_INET, SOCK_DGRAM, 0);
if(p->s < 0)
return NATPMP_ERR_SOCKETERROR;
#ifdef _WIN32
if(p->s == INVALID_SOCKET)
return NATPMP_ERR_SOCKETERROR;
if(ioctlsocket(p->s, FIONBIO, &ioctlArg) == SOCKET_ERROR)
return NATPMP_ERR_FCNTLERROR;
#else
if(p->s < 0)
return NATPMP_ERR_SOCKETERROR;
if((flags = fcntl(p->s, F_GETFL, 0)) < 0)
return NATPMP_ERR_FCNTLERROR;
if(fcntl(p->s, F_SETFL, flags | O_NONBLOCK) < 0)
Expand Down
6 changes: 5 additions & 1 deletion natpmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ typedef unsigned short uint16_t;
#endif

typedef struct {
int s; /* socket */
#ifdef _WIN32
SOCKET s; /* socket */
#else
int s; /* socket */
#endif
in_addr_t gateway; /* default gateway (IPv4) */
int has_pending_request;
unsigned char pending_request[12];
Expand Down