Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

setupnetwork_win32.cpp

Go to the documentation of this file.
00001 /*
00002         ------------------------------------------------------------------------
00003         ClanLib, the platform independent game SDK.
00004 
00005         This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00006         version 2. See COPYING for details.
00007 
00008         For a total list of contributers see CREDITS.
00009 
00010         ------------------------------------------------------------------------
00011 */
00012 
00013 #ifdef WIN32
00014 #pragma warning (disable:4786)
00015 #endif
00016 
00017 #include "API/Network/setupnetwork.h"
00018 #include "API/Core/System/cl_assert.h"
00019 #include "connection_provider_win32.h"
00020 
00021 CL_ConnectionProvider *connection_provider = NULL;
00022 static ref_count = 0;
00023 
00025 // Initialize network.
00026 
00027 void CL_SetupNetwork::init()
00028 {
00029         ref_count++;
00030         if (ref_count > 1) return;
00031 
00032         WORD winsock_version = MAKEWORD( 2, 0 ); 
00033         WSADATA wsaData;
00034         int err = WSAStartup(winsock_version, &wsaData);
00035 
00036         // Failed to initialize winsockets. You got some weird ancient windows 95 or something?
00037         cl_assert(err == 0);
00038 
00039         connection_provider = new CL_Connections_Win32;
00040 }
00041 
00043 // Deinitialize network.
00044 
00045 void CL_SetupNetwork::deinit()
00046 {
00047         ref_count--;
00048         if (ref_count > 0) return;
00049 
00050         delete connection_provider;
00051 }

Generated at Wed Apr 4 19:54:03 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001