initialize Winsock in python module

fixes #221
This commit is contained in:
Thomas Bernard 2016-12-28 10:16:47 +01:00
parent 3571a41d1b
commit 9e73075752
1 changed files with 9 additions and 1 deletions

View File

@ -2,7 +2,7 @@
/* Project : miniupnp
* Author : Thomas BERNARD
* website : http://miniupnp.tuxfamily.org/
* copyright (c) 2007-2014 Thomas Bernard
* copyright (c) 2007-2016 Thomas Bernard
* This software is subjet to the conditions detailed in the
* provided LICENCE file. */
#include <Python.h>
@ -12,6 +12,10 @@
#include "upnpcommands.h"
#include "upnperrors.h"
#ifdef _WIN32
#include <winsock2.h>
#endif
/* for compatibility with Python < 2.4 */
#ifndef Py_RETURN_NONE
#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
@ -669,6 +673,10 @@ initminiupnpc(void)
PyObject* m;
#ifdef _WIN32
/* initialize Winsock. */
WSADATA wsaData;
int nResult = WSAStartup(MAKEWORD(2,2), &wsaData);
UPnPType.tp_new = PyType_GenericNew;
#endif
if (PyType_Ready(&UPnPType) < 0)