From 6cb0522ecbbf60872270ce8835fce2a9366534a2 Mon Sep 17 00:00:00 2001 From: Christian Beier Date: Tue, 21 Feb 2017 19:37:43 +0100 Subject: [PATCH] rfbInitServer: only init Winsock once --- libvncserver/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libvncserver/main.c b/libvncserver/main.c index 27b5437..95c3da5 100644 --- a/libvncserver/main.c +++ b/libvncserver/main.c @@ -1061,7 +1061,15 @@ void rfbInitServer(rfbScreenInfoPtr screen) { #ifdef WIN32 WSADATA trash; - WSAStartup(MAKEWORD(2,2),&trash); + static rfbBool WSAinitted=FALSE; + if(!WSAinitted) { + int i=WSAStartup(MAKEWORD(2,0),&trash); + if(i!=0) { + rfbErr("Couldn't init Windows Sockets\n"); + return 0; + } + WSAinitted=TRUE; + } #endif rfbInitSockets(screen); rfbHttpInitSockets(screen);