Browse Source

Call WSAStartup for our own needs independently of libcurl etc

Luke Dashjr 12 years ago
parent
commit
66f671cc56
1 changed files with 13 additions and 0 deletions
  1. 13 0
      miner.c

+ 13 - 0
miner.c

@@ -9137,6 +9137,10 @@ void _bfg_clean_up(void)
 		free(cpus);
 
 	curl_global_cleanup();
+	
+#ifdef WIN32
+	WSACleanup();
+#endif
 }
 
 void _quit(int status)
@@ -9818,6 +9822,15 @@ int main(int argc, char *argv[])
 	setup_pthread_cancel_workaround();
 #endif
 
+#ifdef WIN32
+	{
+		WSADATA wsa;
+		i = WSAStartup(MAKEWORD(2, 2), &wsa);
+		if (i)
+			quit(1, "Failed to initialise Winsock: %s", bfg_strerror(i, BST_SOCKET));
+	}
+#endif
+	
 	/* This dangerous functions tramples random dynamically allocated
 	 * variables so do it before anything at all */
 	if (unlikely(curl_global_init(CURL_GLOBAL_ALL)))