View previous topic :: View next topic |
Author |
Message |
PortmappingGuru
Joined: 06 Feb 2011 Posts: 8
|
Posted: Sun Feb 06, 2011 12:30 pm Post subject: upnpDiscover(), Socket Error |
|
|
Hi!
I'm trying to make a small console based application, that automatically opens a port on my router. First I try to find the router through upnpDiscover, but all I get is a Socket Error. I guess it has something to do with the minissdpdsock. I'm using Visual Studio 2010 and am developing for Win32 (my OS: Win7).
Code: |
#include <stdio.h>
#include <conio.h>
#include <winsock2.h>
#define STATICLIB
#include "Dependency\miniupnpc.h"
#include "Dependency\miniwget.h"
#include "Dependency\upnpcommands.h"
#include "Dependency\upnperrors.h"
struct UPNPDev *devices;
void main()
{
printf("This is a UPnP test!\n\n");
printf("Searching for UPnP devices!\n");
devices = upnpDiscover(30, NULL, NULL, 0);
if(devices != NULL)
{
printf("UPnP devices were found!\n");
freeUPNPDevlist(devices);
}
_getch();
}
|
This is the Output:
---------------------
This is a UPnP test!
Searching for UPnP devices!
Socket error: socket, 10093
---------------------
What am I doing wrong?
Thanks for your help! |
|
Back to top |
|
|
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1589
|
Posted: Mon Feb 07, 2011 12:15 am Post subject: |
|
|
You havent made the initialisation of Winsock.
Code: |
WSADATA wsaData;
int nResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if(nResult != NO_ERROR)
{
fprintf(stderr, "WSAStartup() failed.\n");
return -1;
}
|
_________________ Main miniUPnP author.
https://miniupnp.tuxfamily.org/ |
|
Back to top |
|
|
PortmappingGuru
Joined: 06 Feb 2011 Posts: 8
|
Posted: Mon Feb 07, 2011 10:25 am Post subject: |
|
|
Ah ok. I thought this is done by miniupnpc automatically.
Thanks a lot for your help! Now it's working |
|
Back to top |
|
|
|