blob: cfbc2959fa0c3b9726264699aafab8dc606e2734 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#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;
};
|