Rudiments
winsock.h
1 // Copyright (c) 2011 David Muse
2 // See the COPYING file for more information.
3 
4 #ifndef RUDIMENTS_WINSOCK_H
5 #define RUDIMENTS_WINSOCK_H
6 
7 #include <rudiments/private/config.h>
8 
9 #ifdef RUDIMENTS_HAVE_WINSOCK2_H
10  #include <rudiments/mutex.h>
11  #include <winsock2.h>
12 #endif
13 
14 // must be included after winsock2.h
15 #ifdef RUDIMENTS_HAVE_WINDOWS_H
16  #include <windows.h>
17 #endif
18 
19 #ifdef RUDIMENTS_NAMESPACE
20 namespace rudiments {
21 #endif
22 
23 class winsock {
24  public:
25  static bool initWinsock();
26  static void shutDownWinsock();
27  private:
28  #ifdef RUDIMENTS_HAVE_WINSOCK2_H
29  static bool _initialized;
30  static mutex _winsockmutex;
31  static WSADATA _wsadata;
32  #endif
33 };
34 
35 #ifdef RUDIMENTS_NAMESPACE
36 }
37 #endif
38 
39 #endif