summaryrefslogtreecommitdiffstats
path: root/source/cSocket.h
diff options
context:
space:
mode:
authorcedeel@gmail.com <cedeel@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-14 15:06:06 +0200
committercedeel@gmail.com <cedeel@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-14 15:06:06 +0200
commit92c59963f82f81aa3202657e7fdbb2592924ede3 (patch)
treeb7eb2474528a4998fa102e3ec9119b908cee08b4 /source/cSocket.h
parentAdded HOOK_WEATHER_CHANGE. (diff)
downloadcuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.gz
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.bz2
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.lz
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.xz
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.zst
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.zip
Diffstat (limited to 'source/cSocket.h')
-rw-r--r--source/cSocket.h172
1 files changed, 86 insertions, 86 deletions
diff --git a/source/cSocket.h b/source/cSocket.h
index 21a7cf3c2..0ed7b1a4e 100644
--- a/source/cSocket.h
+++ b/source/cSocket.h
@@ -1,87 +1,87 @@
-
-#pragma once
-
-
-
-
-
-class cPacket;
-
-
-
-
-
-class cSocket
-{
-public:
-#ifdef _WIN32
- typedef SOCKET xSocket;
-#else
- typedef int xSocket;
- static const int INVALID_SOCKET = -1;
-#endif
-
- cSocket(void) : m_Socket(INVALID_SOCKET) {}
- cSocket(xSocket a_Socket);
- ~cSocket();
-
- bool IsValid(void) const;
- void CloseSocket();
-
- operator const xSocket() const;
- xSocket GetSocket() const;
-
- bool operator == (const cSocket & a_Other) {return m_Socket == a_Other.m_Socket; }
-
- void SetSocket( xSocket a_Socket );
-
- int SetReuseAddress();
- static int WSAStartup();
-
- static AString GetErrorString( int a_ErrNo );
- static int GetLastError();
- static AString GetLastErrorString(void)
- {
- return GetErrorString(GetLastError());
- }
-
- static cSocket CreateSocket();
-
- inline static bool IsSocketError( int a_ReturnedValue )
- {
-#ifdef _WIN32
- return (a_ReturnedValue == SOCKET_ERROR || a_ReturnedValue == 0);
-#else
- return (a_ReturnedValue <= 0);
-#endif
- }
-
- struct SockAddr_In
- {
- short Family;
- unsigned short Port;
- unsigned long Address;
- };
-
- static const short ADDRESS_FAMILY_INTERNET = 2;
- static const unsigned long INTERNET_ADDRESS_ANY = 0;
- static unsigned long INTERNET_ADDRESS_LOCALHOST(void); // 127.0.0.1 represented in network byteorder; must be a function due to GCC :(
-
- int Bind( SockAddr_In& a_Address );
- int Listen( int a_Backlog );
- cSocket Accept();
- int Connect(SockAddr_In & a_Address); // Returns 0 on success, !0 on failure
- int Connect(const AString & a_HostNameOrAddr, unsigned short a_Port); // Returns 0 on success, !0 on failure
- int Receive( char* a_Buffer, unsigned int a_Length, unsigned int a_Flags );
- int Send (const char * a_Buffer, unsigned int a_Length);
- int Send (const cPacket * a_Packet); // Sends the packet, doesn't handle partial sends
- int Send (const cPacket & a_Packet); // Sends the packet, doesn't handle partial sends
-
- unsigned short GetPort(void) const; // Returns 0 on failure
-
- const AString & GetIPString(void) const { return m_IPString; }
-
-private:
- xSocket m_Socket;
- AString m_IPString;
+
+#pragma once
+
+
+
+
+
+class cPacket;
+
+
+
+
+
+class cSocket
+{
+public:
+#ifdef _WIN32
+ typedef SOCKET xSocket;
+#else
+ typedef int xSocket;
+ static const int INVALID_SOCKET = -1;
+#endif
+
+ cSocket(void) : m_Socket(INVALID_SOCKET) {}
+ cSocket(xSocket a_Socket);
+ ~cSocket();
+
+ bool IsValid(void) const;
+ void CloseSocket();
+
+ operator const xSocket() const;
+ xSocket GetSocket() const;
+
+ bool operator == (const cSocket & a_Other) {return m_Socket == a_Other.m_Socket; }
+
+ void SetSocket( xSocket a_Socket );
+
+ int SetReuseAddress();
+ static int WSAStartup();
+
+ static AString GetErrorString( int a_ErrNo );
+ static int GetLastError();
+ static AString GetLastErrorString(void)
+ {
+ return GetErrorString(GetLastError());
+ }
+
+ static cSocket CreateSocket();
+
+ inline static bool IsSocketError( int a_ReturnedValue )
+ {
+#ifdef _WIN32
+ return (a_ReturnedValue == SOCKET_ERROR || a_ReturnedValue == 0);
+#else
+ return (a_ReturnedValue <= 0);
+#endif
+ }
+
+ struct SockAddr_In
+ {
+ short Family;
+ unsigned short Port;
+ unsigned long Address;
+ };
+
+ static const short ADDRESS_FAMILY_INTERNET = 2;
+ static const unsigned long INTERNET_ADDRESS_ANY = 0;
+ static unsigned long INTERNET_ADDRESS_LOCALHOST(void); // 127.0.0.1 represented in network byteorder; must be a function due to GCC :(
+
+ int Bind( SockAddr_In& a_Address );
+ int Listen( int a_Backlog );
+ cSocket Accept();
+ int Connect(SockAddr_In & a_Address); // Returns 0 on success, !0 on failure
+ int Connect(const AString & a_HostNameOrAddr, unsigned short a_Port); // Returns 0 on success, !0 on failure
+ int Receive( char* a_Buffer, unsigned int a_Length, unsigned int a_Flags );
+ int Send (const char * a_Buffer, unsigned int a_Length);
+ int Send (const cPacket * a_Packet); // Sends the packet, doesn't handle partial sends
+ int Send (const cPacket & a_Packet); // Sends the packet, doesn't handle partial sends
+
+ unsigned short GetPort(void) const; // Returns 0 on failure
+
+ const AString & GetIPString(void) const { return m_IPString; }
+
+private:
+ xSocket m_Socket;
+ AString m_IPString;
}; \ No newline at end of file