diff options
author | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-10-03 20:41:19 +0200 |
---|---|---|
committer | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-10-03 20:41:19 +0200 |
commit | 386d58b5862d8b76925c6523721594887606e82a (patch) | |
tree | ef073e7a843f4b75a4008d4b7383f7cdf08ceee5 /source/cSocket.h | |
parent | Visual Studio 2010 solution and project files (diff) | |
download | cuberite-386d58b5862d8b76925c6523721594887606e82a.tar cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.gz cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.bz2 cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.lz cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.xz cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.zst cuberite-386d58b5862d8b76925c6523721594887606e82a.zip |
Diffstat (limited to 'source/cSocket.h')
-rw-r--r-- | source/cSocket.h | 43 |
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 |