c7b4b9f819
git-svn-id: http://mc-server.googlecode.com/svn/trunk@6 0a769ca7-a7f5-676a-18bf-c427514a06d6
45 lines
715 B
C++
45 lines
715 B
C++
#pragma once
|
|
|
|
#ifdef _WIN32
|
|
#include <WinSock.h>
|
|
#define socklen_t int
|
|
#ifdef SendMessage
|
|
#undef SendMessage
|
|
#endif
|
|
#endif // _WIN32
|
|
|
|
|
|
class cSocket
|
|
{
|
|
#ifdef _WIN32
|
|
typedef SOCKET xSocket;
|
|
#else
|
|
typedef int xSocket;
|
|
#endif
|
|
|
|
public:
|
|
cSocket() : m_Socket( 0 ) {}
|
|
|
|
cSocket( xSocket a_Socket );
|
|
~cSocket();
|
|
|
|
bool IsValid();
|
|
void CloseSocket();
|
|
|
|
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;
|
|
}; |