From 386d58b5862d8b76925c6523721594887606e82a Mon Sep 17 00:00:00 2001 From: faketruth Date: Mon, 3 Oct 2011 18:41:19 +0000 Subject: MCServer c++ source files git-svn-id: http://mc-server.googlecode.com/svn/trunk@3 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cSocket.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 source/cSocket.h (limited to 'source/cSocket.h') 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 +#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 -- cgit v1.2.3