From 48d30d6ab4657e00c0c861d67285256daeff1142 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Wed, 1 Feb 2012 22:38:03 +0000 Subject: Rewritten cAuthenticator to make use of the new cIsThread architecture - now authentication runs in a single separate thread for all clients; Global player-kicking function (cServer, cRoot); More char * -> AString conversion git-svn-id: http://mc-server.googlecode.com/svn/trunk@221 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cSocket.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 9 deletions(-) (limited to 'source/cSocket.cpp') diff --git a/source/cSocket.cpp b/source/cSocket.cpp index c8b651342..bd26fb274 100644 --- a/source/cSocket.cpp +++ b/source/cSocket.cpp @@ -23,28 +23,35 @@ cSocket::cSocket( xSocket a_Socket ) { } + + + + cSocket::~cSocket() { } + + + + cSocket::operator const cSocket::xSocket() const { return m_Socket; } + + + + cSocket::xSocket cSocket::GetSocket() const { return m_Socket; } -bool cSocket::IsValid() -{ -#ifdef _WIN32 - return ( m_Socket != INVALID_SOCKET); -#else - return ( m_Socket >= 0); -#endif -} + + + void cSocket::CloseSocket() { @@ -58,6 +65,10 @@ void cSocket::CloseSocket() #endif } + + + + const char* cSocket::GetLastErrorString() { #define CASE_AND_RETURN( x ) case x: return #x @@ -88,6 +99,10 @@ const char* cSocket::GetLastErrorString() #endif } + + + + int cSocket::SetReuseAddress() { #ifdef _WIN32 @@ -98,6 +113,10 @@ int cSocket::SetReuseAddress() return setsockopt( m_Socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int) ); } + + + + int cSocket::WSAStartup() { #ifdef _WIN32 @@ -109,11 +128,19 @@ int cSocket::WSAStartup() #endif } + + + + cSocket cSocket::CreateSocket() { return socket(AF_INET,SOCK_STREAM,0); } + + + + int cSocket::Bind( SockAddr_In& a_Address ) { sockaddr_in local; @@ -129,11 +156,19 @@ int cSocket::Bind( SockAddr_In& a_Address ) return bind( m_Socket, (sockaddr*)&local, sizeof(local)); } + + + + int cSocket::Listen( int a_Backlog ) { return listen( m_Socket, a_Backlog ); } + + + + cSocket cSocket::Accept() { sockaddr_in from; @@ -150,7 +185,15 @@ cSocket cSocket::Accept() return SClient; } + + + + int cSocket::Receive( char* a_Buffer, unsigned int a_Length, unsigned int a_Flags ) { return recv(m_Socket, a_Buffer, a_Length, a_Flags); -} \ No newline at end of file +} + + + + -- cgit v1.2.3