From b7d524423c23470cd11e720eeb48368c072838cb Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Tue, 7 Feb 2012 20:49:52 +0000 Subject: Rewritten all packets to use buffers instead of direct sockets, for future cSocketThreads compatibility. Moved data sending from cPacket into cSocket git-svn-id: http://mc-server.googlecode.com/svn/trunk@240 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cSocket.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'source/cSocket.cpp') diff --git a/source/cSocket.cpp b/source/cSocket.cpp index 90c31f58d..fa016762c 100644 --- a/source/cSocket.cpp +++ b/source/cSocket.cpp @@ -2,12 +2,11 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "cSocket.h" +#include "packets/cPacket.h" #ifndef _WIN32 #include #include - // #include - // #include #include //inet_ntoa() #else #define socklen_t int @@ -273,6 +272,28 @@ int cSocket::Send(const char * a_Buffer, unsigned int a_Length) +int cSocket::Send(const cPacket * a_Packet) +{ + AString Serialized; + a_Packet->Serialize(Serialized); + return Send(Serialized.data(), Serialized.size()); +} + + + + + +int cSocket::Send(const cPacket & a_Packet) +{ + AString Serialized; + a_Packet.Serialize(Serialized); + return Send(Serialized.data(), Serialized.size()); +} + + + + + unsigned short cSocket::GetPort(void) const { assert(IsValid()); -- cgit v1.2.3