]> git.donarmstrong.com Git - bamtools.git/blob - src/api/internal/io/NetWin_p.h
fb138b241e559452d545fc97352400610193c5b7
[bamtools.git] / src / api / internal / io / NetWin_p.h
1 #ifndef NETWIN_P_H
2 #define NETWIN_P_H
3
4 #ifdef _WIN32 // <-- source files only include the proper Net*_p.h, but this is a double-check
5
6 #include <winsock2.h>  // <-- should bring 'windows.h' along with it
7 #include <Ws2tcpip.h>
8
9 #ifndef   BT_SOCKLEN_T
10 #  define BT_SOCKLEN_T int
11 #endif
12
13 #ifdef _MSC_VER
14 #  pragma comment(lib, "ws2_32.lib")
15 #endif
16
17 namespace BamTools {
18 namespace Internal {
19
20 // use RAII to ensure WSA is en
21 class WindowsSockInit {
22     public:
23         WindowsSockInit(void) {
24             WSAData wsadata;
25             WSAStartup(MAKEWORD(2,2), &wsadata); // catch error ?
26         }
27
28         ~WindowsSockInit(void) {
29             WSACleanup();
30         }
31 };
32
33 } // namespace Internal
34 } // namespace BamTools
35
36 #endif // _WIN32
37
38 #endif // NETWIN_P_H
39