]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/api/internal/io/NetWin_p.h
Added FTP support (text-tested, not BAM)
[bamtools.git] / src / api / internal / io / NetWin_p.h
diff --git a/src/api/internal/io/NetWin_p.h b/src/api/internal/io/NetWin_p.h
new file mode 100644 (file)
index 0000000..fb138b2
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef NETWIN_P_H
+#define NETWIN_P_H
+
+#ifdef _WIN32 // <-- source files only include the proper Net*_p.h, but this is a double-check
+
+#include <winsock2.h>  // <-- should bring 'windows.h' along with it
+#include <Ws2tcpip.h>
+
+#ifndef   BT_SOCKLEN_T
+#  define BT_SOCKLEN_T int
+#endif
+
+#ifdef _MSC_VER
+#  pragma comment(lib, "ws2_32.lib")
+#endif
+
+namespace BamTools {
+namespace Internal {
+
+// use RAII to ensure WSA is en
+class WindowsSockInit {
+    public:
+        WindowsSockInit(void) {
+            WSAData wsadata;
+            WSAStartup(MAKEWORD(2,2), &wsadata); // catch error ?
+        }
+
+        ~WindowsSockInit(void) {
+            WSACleanup();
+        }
+};
+
+} // namespace Internal
+} // namespace BamTools
+
+#endif // _WIN32
+
+#endif // NETWIN_P_H
+