summaryrefslogtreecommitdiffstats
path: root/source/cSocket.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/cSocket.h')
-rw-r--r--source/cSocket.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/source/cSocket.h b/source/cSocket.h
new file mode 100644
index 000000000..4a58ff2c9
--- /dev/null
+++ b/source/cSocket.h
@@ -0,0 +1,43 @@
+#pragma once
+
+#ifdef _WIN32
+#include <WinSock.h>
+#define socklen_t int
+#ifdef SendMessage
+#undef SendMessage
+#endif
+#endif
+
+class cSocket
+{
+#ifdef _WIN32
+ typedef SOCKET xSocket;
+#else
+ typedef int xSocket;
+#endif
+
+public:
+ cSocket() : m_Socket( 0 ) {}
+
+ cSocket( xSocket a_Socket );
+ ~cSocket();
+
+ bool IsValid();
+
+ operator const xSocket() const;
+ xSocket GetSocket() const;
+ void SetSocket( xSocket a_Socket );
+
+ inline static bool IsSocketError( int a_ReturnedValue )
+ {
+#ifdef _WIN32
+ return (a_ReturnedValue == SOCKET_ERROR || a_ReturnedValue == 0);
+#else
+ return (a_ReturnedValue <= 0);
+#endif
+ }
+
+
+private:
+ xSocket m_Socket;
+}; \ No newline at end of file