From cf94994f8e3b34bc871e2c3b2558f8301146810c Mon Sep 17 00:00:00 2001 From: faketruth Date: Sun, 23 Oct 2011 00:18:44 +0000 Subject: Abstracted sockets some more to ensure the same behavior over the entire program and on multiple platforms. MCSocket.h should soon be deprecated and deleted Do a full rebuild (mine bugged out when I didn't) git-svn-id: http://mc-server.googlecode.com/svn/trunk@8 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cSocket.h | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'source/cSocket.h') diff --git a/source/cSocket.h b/source/cSocket.h index cfbc2959f..dde268a8a 100644 --- a/source/cSocket.h +++ b/source/cSocket.h @@ -1,8 +1,8 @@ #pragma once #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN #include -#define socklen_t int #ifdef SendMessage #undef SendMessage #endif @@ -30,6 +30,12 @@ public: xSocket GetSocket() const; void SetSocket( xSocket a_Socket ); + int SetReuseAddress(); + static int WSAStartup(); + + static const char* GetLastErrorString(); + static cSocket CreateSocket(); + inline static bool IsSocketError( int a_ReturnedValue ) { #ifdef _WIN32 @@ -39,7 +45,24 @@ public: #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; + + int Bind( SockAddr_In& a_Address ); + int Listen( int a_Backlog ); + cSocket Accept(); + int Receive( char* a_Buffer, unsigned int a_Length, unsigned int a_Flags ); + + char* GetIPString() { return m_IPString; } + private: xSocket m_Socket; + char* m_IPString; }; \ No newline at end of file -- cgit v1.2.3