From d8e28fbf9056ccd0881d0f9b4316acdd8818e3c1 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Mon, 17 Jan 2011 21:31:59 +0000 Subject: [PATCH] - attempt to fix WSAStartup error message on win32 --- source/glest_game/main/main.cpp | 4 ++++ .../include/platform/posix/socket.h | 23 ++++++++----------- .../sources/platform/posix/socket.cpp | 6 ++--- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index c4f1113f..575945d3 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -1379,6 +1379,10 @@ int glestMain(int argc, char** argv) { disableBacktrace = true; } +#ifdef WIN32 + SocketManager winSockManager; +#endif + bool haveSpecialOutputCommandLineOption = false; if( hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_OPENGL_INFO]) == true || diff --git a/source/shared_lib/include/platform/posix/socket.h b/source/shared_lib/include/platform/posix/socket.h index 3c1dd31a..2eb4e8b1 100644 --- a/source/shared_lib/include/platform/posix/socket.h +++ b/source/shared_lib/include/platform/posix/socket.h @@ -92,23 +92,20 @@ public: // class Socket // ===================================================== -class Socket : public SimpleTaskCallbackInterface { - #ifdef WIN32 - -private: - class SocketManager{ - public: - SocketManager(); - ~SocketManager(); - }; - -protected: - static SocketManager socketManager; - +class SocketManager{ +public: + SocketManager(); + ~SocketManager(); +}; #endif +class Socket : public SimpleTaskCallbackInterface { + protected: +#ifdef WIN32 + SocketManager wsaManager; +#endif PLATFORM_SOCKET sock; time_t lastDebugEvent; static int broadcast_portno; diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 02237880..845ff62a 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -214,9 +214,9 @@ bool UPNP_Tools::enabledUPNP = false; return acErrorBuffer; } - Socket::SocketManager Socket::socketManager; + //SocketManager Socket::socketManager; - Socket::SocketManager::SocketManager(){ + SocketManager::SocketManager() { WSADATA wsaData; WORD wVersionRequested = MAKEWORD(2, 0); WSAStartup(wVersionRequested, &wsaData); @@ -224,7 +224,7 @@ bool UPNP_Tools::enabledUPNP = false; SystemFlags::OutputDebug(SystemFlags::debugNetwork,"Winsock initialized.\n"); } - Socket::SocketManager::~SocketManager(){ + SocketManager::~SocketManager() { WSACleanup(); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"Winsock cleanup complete.\n"); }