From 151f3fe3dacae9048947fecdf3e179cd6ab9dcfb Mon Sep 17 00:00:00 2001 From: Frank Morgner Date: Mon, 17 Mar 2014 20:29:09 +0100 Subject: [PATCH] correctly initialize winsock --- virtualsmartcard/src/vpcd/vpcd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/virtualsmartcard/src/vpcd/vpcd.c b/virtualsmartcard/src/vpcd/vpcd.c index 7f0517c..2fc359e 100644 --- a/virtualsmartcard/src/vpcd/vpcd.c +++ b/virtualsmartcard/src/vpcd/vpcd.c @@ -254,6 +254,11 @@ struct vicc_ctx * vicc_init(const char *hostname, unsigned short port) return NULL; } +#ifdef _WIN32 + WSADATA wsaData; + WSAStartup(MAKEWORD(2, 2), &wsaData); +#endif + if (hostname) { ctx->hostname = strdup(hostname); if (!ctx->hostname) { @@ -291,6 +296,9 @@ int vicc_exit(struct vicc_ctx *ctx) r -= 1; } } +#ifdef _WIN32 + WSACleanup(); +#endif } return r;