summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-04-30 17:06:31 +0200
committermadmaxoft <github@xoft.cz>2014-04-30 17:06:46 +0200
commit58929a994830329120c68bf43cf6fcb8a90be960 (patch)
tree58873e201de6481999a0f0d696679d381db2ed77
parentMerge pull request #965 from mc-server/SslWrappers (diff)
downloadcuberite-58929a994830329120c68bf43cf6fcb8a90be960.tar
cuberite-58929a994830329120c68bf43cf6fcb8a90be960.tar.gz
cuberite-58929a994830329120c68bf43cf6fcb8a90be960.tar.bz2
cuberite-58929a994830329120c68bf43cf6fcb8a90be960.tar.lz
cuberite-58929a994830329120c68bf43cf6fcb8a90be960.tar.xz
cuberite-58929a994830329120c68bf43cf6fcb8a90be960.tar.zst
cuberite-58929a994830329120c68bf43cf6fcb8a90be960.zip
Diffstat (limited to '')
-rw-r--r--src/OSSupport/BlockingTCPLink.cpp142
-rw-r--r--src/OSSupport/BlockingTCPLink.h28
-rw-r--r--src/Protocol/Authenticator.cpp1
3 files changed, 0 insertions, 171 deletions
diff --git a/src/OSSupport/BlockingTCPLink.cpp b/src/OSSupport/BlockingTCPLink.cpp
deleted file mode 100644
index 07f48b955..000000000
--- a/src/OSSupport/BlockingTCPLink.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "BlockingTCPLink.h"
-#include "Errors.h"
-
-
-
-
-cBlockingTCPLink::cBlockingTCPLink(void)
-{
-}
-
-
-
-
-
-cBlockingTCPLink::~cBlockingTCPLink()
-{
- CloseSocket();
-}
-
-
-
-
-
-void cBlockingTCPLink::CloseSocket()
-{
- if (!m_Socket.IsValid())
- {
- m_Socket.CloseSocket();
- }
-}
-
-
-
-
-
-bool cBlockingTCPLink::Connect(const char * iAddress, unsigned int iPort)
-{
- ASSERT(!m_Socket.IsValid());
- if (m_Socket.IsValid())
- {
- LOGWARN("WARNING: cTCPLink Connect() called while still connected.");
- m_Socket.CloseSocket();
- }
-
- struct hostent *hp;
- unsigned int addr;
- struct sockaddr_in server;
-
- m_Socket = socket(AF_INET, SOCK_STREAM, 0);
- if (!m_Socket.IsValid())
- {
- LOGERROR("cTCPLink: Cannot create a socket");
- return false;
- }
-
- addr = inet_addr(iAddress);
- hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET);
- if (hp == NULL)
- {
- //LOGWARN("cTCPLink: gethostbyaddr returned NULL");
- hp = gethostbyname(iAddress);
- if (hp == NULL)
- {
- LOGWARN("cTCPLink: Could not resolve %s", iAddress);
- CloseSocket();
- return false;
- }
- }
-
- memcpy(&server.sin_addr.s_addr,hp->h_addr, hp->h_length);
- server.sin_family = AF_INET;
- server.sin_port = htons( (unsigned short)iPort);
- if (connect(m_Socket, (struct sockaddr *)&server, sizeof(server)))
- {
- LOGWARN("cTCPLink: Connection to \"%s:%d\" failed (%s)", iAddress, iPort,GetOSErrorString( cSocket::GetLastError() ).c_str() );
- CloseSocket();
- return false;
- }
-
- return true;
-}
-
-
-
-
-
-int cBlockingTCPLink::Send(char * a_Data, unsigned int a_Size, int a_Flags /* = 0 */ )
-{
- UNUSED(a_Flags);
-
- ASSERT(m_Socket.IsValid());
- if (!m_Socket.IsValid())
- {
- LOGERROR("cBlockingTCPLink: Trying to send data without a valid connection!");
- return -1;
- }
- return m_Socket.Send(a_Data, a_Size);
-}
-
-
-
-
-
-int cBlockingTCPLink::SendMessage( const char* a_Message, int a_Flags /* = 0 */ )
-{
- UNUSED(a_Flags);
-
- ASSERT(m_Socket.IsValid());
- if (!m_Socket.IsValid())
- {
- LOGWARN("cBlockingTCPLink: Trying to send message without a valid connection!");
- return -1;
- }
- return m_Socket.Send(a_Message, strlen(a_Message));
-}
-
-
-
-
-
-void cBlockingTCPLink::ReceiveData(AString & oData)
-{
- ASSERT(m_Socket.IsValid());
- if (!m_Socket.IsValid())
- {
- return;
- }
-
- int Received = 0;
- char Buffer[256];
- while ((Received = recv(m_Socket, Buffer, sizeof(Buffer), 0)) > 0)
- {
- oData.append(Buffer, Received);
- }
-}
-
-
-
-
diff --git a/src/OSSupport/BlockingTCPLink.h b/src/OSSupport/BlockingTCPLink.h
deleted file mode 100644
index cb5f9e3f4..000000000
--- a/src/OSSupport/BlockingTCPLink.h
+++ /dev/null
@@ -1,28 +0,0 @@
-
-#pragma once
-
-#include "Socket.h"
-
-
-
-
-
-class cBlockingTCPLink // tolua_export
-{ // tolua_export
-public: // tolua_export
- cBlockingTCPLink(void); // tolua_export
- ~cBlockingTCPLink(); // tolua_export
-
- bool Connect( const char* a_Address, unsigned int a_Port ); // tolua_export
- int Send( char* a_Data, unsigned int a_Size, int a_Flags = 0 ); // tolua_export
- int SendMessage( const char* a_Message, int a_Flags = 0 ); // tolua_export
- void CloseSocket(); // tolua_export
- void ReceiveData(AString & oData); // tolua_export
-protected:
-
- cSocket m_Socket;
-}; // tolua_export
-
-
-
-
diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp
index 8100b6395..41d614e58 100644
--- a/src/Protocol/Authenticator.cpp
+++ b/src/Protocol/Authenticator.cpp
@@ -2,7 +2,6 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Authenticator.h"
-#include "../OSSupport/BlockingTCPLink.h"
#include "../Root.h"
#include "../Server.h"
#include "../ClientHandle.h"