2011-10-03 11:41:19 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include <WinSock.h>
|
|
|
|
#define socklen_t int
|
|
|
|
#ifdef SendMessage
|
|
|
|
#undef SendMessage
|
|
|
|
#endif
|
2011-10-21 14:25:29 -07:00
|
|
|
#endif // _WIN32
|
|
|
|
|
2011-10-03 11:41:19 -07:00
|
|
|
|
|
|
|
class cSocket
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
typedef SOCKET xSocket;
|
|
|
|
#else
|
|
|
|
typedef int xSocket;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
public:
|
|
|
|
cSocket() : m_Socket( 0 ) {}
|
|
|
|
|
|
|
|
cSocket( xSocket a_Socket );
|
|
|
|
~cSocket();
|
|
|
|
|
|
|
|
bool IsValid();
|
2011-10-21 14:25:29 -07:00
|
|
|
void CloseSocket();
|
2011-10-03 11:41:19 -07:00
|
|
|
|
|
|
|
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;
|
|
|
|
};
|