ProtoProxy: Fixed compilation in Windows and in Linux.
This commit is contained in:
parent
c7b67d9c3c
commit
c4f4eda347
@ -249,12 +249,10 @@ void cConnection::Run(void)
|
|||||||
|
|
||||||
void cConnection::Log(const char * a_Format, ...)
|
void cConnection::Log(const char * a_Format, ...)
|
||||||
{
|
{
|
||||||
va_list args, argsCopy;
|
va_list args;
|
||||||
va_start(args, a_Format);
|
va_start(args, a_Format);
|
||||||
va_start(argsCopy, a_Format);
|
|
||||||
AString msg;
|
AString msg;
|
||||||
AppendVPrintf(msg, a_Format, args, argsCopy);
|
AppendVPrintf(msg, a_Format, args);
|
||||||
va_end(argsCopy);
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
AString FullMsg;
|
AString FullMsg;
|
||||||
Printf(FullMsg, "[%5.3f] %s\n", GetRelativeTime(), msg.c_str());
|
Printf(FullMsg, "[%5.3f] %s\n", GetRelativeTime(), msg.c_str());
|
||||||
@ -276,12 +274,10 @@ void cConnection::Log(const char * a_Format, ...)
|
|||||||
|
|
||||||
void cConnection::DataLog(const void * a_Data, int a_Size, const char * a_Format, ...)
|
void cConnection::DataLog(const void * a_Data, int a_Size, const char * a_Format, ...)
|
||||||
{
|
{
|
||||||
va_list args, argsCopy;
|
va_list args;
|
||||||
va_start(args, a_Format);
|
va_start(args, a_Format);
|
||||||
va_start(argsCopy, a_Format);
|
|
||||||
AString msg;
|
AString msg;
|
||||||
AppendVPrintf(msg, a_Format, args, argsCopy);
|
AppendVPrintf(msg, a_Format, args);
|
||||||
va_end(argsCopy);
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
AString FullMsg;
|
AString FullMsg;
|
||||||
AString Hex;
|
AString Hex;
|
||||||
|
@ -123,6 +123,12 @@ typedef unsigned short UInt16;
|
|||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
typedef SOCKET int;
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
INVALID_SOCKET = -1,
|
||||||
|
};
|
||||||
#if !defined(ANDROID_NDK)
|
#if !defined(ANDROID_NDK)
|
||||||
#include <tr1/memory>
|
#include <tr1/memory>
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,6 +22,8 @@ cServer::cServer(void)
|
|||||||
int cServer::Init(short a_ListenPort, short a_ConnectPort)
|
int cServer::Init(short a_ListenPort, short a_ConnectPort)
|
||||||
{
|
{
|
||||||
m_ConnectPort = a_ConnectPort;
|
m_ConnectPort = a_ConnectPort;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
WSAData wsa;
|
WSAData wsa;
|
||||||
int res = WSAStartup(0x0202, &wsa);
|
int res = WSAStartup(0x0202, &wsa);
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
@ -29,6 +31,7 @@ int cServer::Init(short a_ListenPort, short a_ConnectPort)
|
|||||||
printf("Cannot initialize WinSock: %d\n", res);
|
printf("Cannot initialize WinSock: %d\n", res);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
printf("Generating protocol encryption keypair...\n");
|
printf("Generating protocol encryption keypair...\n");
|
||||||
time_t CurTime = time(NULL);
|
time_t CurTime = time(NULL);
|
||||||
@ -62,7 +65,7 @@ void cServer::Run(void)
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
sockaddr_in Addr;
|
sockaddr_in Addr;
|
||||||
ZeroMemory(&Addr, sizeof(Addr));
|
memset(&Addr, 0, sizeof(Addr));
|
||||||
int AddrSize = sizeof(Addr);
|
int AddrSize = sizeof(Addr);
|
||||||
SOCKET client = accept(m_ListenSocket, (sockaddr *)&Addr, &AddrSize);
|
SOCKET client = accept(m_ListenSocket, (sockaddr *)&Addr, &AddrSize);
|
||||||
if (client == INVALID_SOCKET)
|
if (client == INVALID_SOCKET)
|
||||||
|
Loading…
Reference in New Issue
Block a user