fix comm bug.
This commit is contained in:
parent
3ece3011f0
commit
de07b21cbd
|
@ -40,7 +40,6 @@ DWORD MyFile::Read( DWORD dwToRead, ByteBuffer& buffer )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buffer.Free();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +65,6 @@ BOOL MyFile::ReadAll( ByteBuffer& buffer )
|
||||||
DWORD dwFileSize = ::GetFileSize(m_handle, NULL);
|
DWORD dwFileSize = ::GetFileSize(m_handle, NULL);
|
||||||
if (0 == dwFileSize)
|
if (0 == dwFileSize)
|
||||||
{
|
{
|
||||||
buffer.Free();
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +85,6 @@ BOOL MyFile::ReadAll( ByteBuffer& buffer )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buffer.Free();
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
LPTSTR para[] = {_T("servant")};
|
LPTSTR para[] = {_T("servant")};
|
||||||
fnServiceMain(TRUE);
|
fnServiceMain(FALSE);
|
||||||
|
|
||||||
while(TRUE) Sleep(500);
|
while(TRUE) Sleep(500);
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,9 @@ BOOL CommManager::Send( COMM_NAME commName, ULONG targetIP, const LPBYTE pData,
|
||||||
|
|
||||||
XorFibonacciCrypt(pData, dwSize, (LPVOID)(LPBYTE)buffer, 2, 7);
|
XorFibonacciCrypt(pData, dwSize, (LPVOID)(LPBYTE)buffer, 2, 7);
|
||||||
|
|
||||||
return m_commList[commName]->Send(targetIP, (LPBYTE)buffer, dwSize);
|
BOOL ret = m_commList[commName]->Send(targetIP, (LPBYTE)buffer, dwSize);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CommManager::SendAndRecv( COMM_NAME commName, ULONG targetIP, const LPBYTE pSendData, DWORD dwSendSize, ByteBuffer& recvData )
|
BOOL CommManager::SendAndRecv( COMM_NAME commName, ULONG targetIP, const LPBYTE pSendData, DWORD dwSendSize, ByteBuffer& recvData )
|
||||||
|
@ -90,6 +92,7 @@ BOOL CommManager::SendAndRecv( COMM_NAME commName, ULONG targetIP, const LPBYTE
|
||||||
LPBYTE pRecvData = NULL;
|
LPBYTE pRecvData = NULL;
|
||||||
DWORD dwRecvSize = 0;
|
DWORD dwRecvSize = 0;
|
||||||
BOOL bRet = m_commList[commName]->SendAndRecv(targetIP, (LPBYTE)sendBuffer, dwSendSize, &pRecvData, dwRecvSize);
|
BOOL bRet = m_commList[commName]->SendAndRecv(targetIP, (LPBYTE)sendBuffer, dwSendSize, &pRecvData, dwRecvSize);
|
||||||
|
|
||||||
if (! bRet)
|
if (! bRet)
|
||||||
{
|
{
|
||||||
errorLog(_T("send and recv[%d] failed"), commName);
|
errorLog(_T("send and recv[%d] failed"), commName);
|
||||||
|
@ -139,13 +142,13 @@ BOOL CommManager::PushMsgToMaster( COMM_NAME commName, const CommData& data, CPS
|
||||||
debugLog(_T("put message [%I64u][%I64u]"), data.GetMsgID(), data.GetSerialID());
|
debugLog(_T("put message [%I64u][%I64u]"), data.GetMsgID(), data.GetSerialID());
|
||||||
|
|
||||||
CPGUID serverGuid = {0};
|
CPGUID serverGuid = {0};
|
||||||
if (! m_cp.PutMessage(serverGuid, byteData, byteData.Size(), commName, dwMaxDataSizePerPacket, pCPSerial, data.GetMsgID()))
|
|
||||||
{
|
BOOL ret = m_cp.PutMessage(serverGuid, byteData, byteData.Size(), commName, dwMaxDataSizePerPacket, pCPSerial, data.GetMsgID());
|
||||||
errorLog(_T("put msg to cp failed"));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
if (! ret)
|
||||||
|
errorLog(_T("put msg to cp failed"));
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommManager::CleanMsgByMSGID(MSGID msgid)
|
void CommManager::CleanMsgByMSGID(MSGID msgid)
|
||||||
|
@ -286,6 +289,8 @@ void CommManager::MessageSenderProc()
|
||||||
BOOL bFirstConnect = TRUE;
|
BOOL bFirstConnect = TRUE;
|
||||||
BOOL bWaitUntil = (g_ConfigInfo.nFirstConnectHour >= 0 && g_ConfigInfo.nFirstConnectMinute >= 0);
|
BOOL bWaitUntil = (g_ConfigInfo.nFirstConnectHour >= 0 && g_ConfigInfo.nFirstConnectMinute >= 0);
|
||||||
|
|
||||||
|
ByteBuffer recvByteData;
|
||||||
|
|
||||||
while (m_bWorking)
|
while (m_bWorking)
|
||||||
{
|
{
|
||||||
if (! m_bWorking) break;
|
if (! m_bWorking) break;
|
||||||
|
@ -326,9 +331,12 @@ void CommManager::MessageSenderProc()
|
||||||
|
|
||||||
//发送并接收
|
//发送并接收
|
||||||
/*if (! IsCommAvailable(commName)) continue;*/
|
/*if (! IsCommAvailable(commName)) continue;*/
|
||||||
ByteBuffer recvByteData;
|
|
||||||
|
|
||||||
if (! SendAndRecv(commName, targetIP, toSendByteData, toSendByteData.Size(), recvByteData))
|
BOOL ret = SendAndRecv(commName, targetIP, toSendByteData, toSendByteData.Size(), recvByteData);
|
||||||
|
|
||||||
|
toSendByteData.Free();
|
||||||
|
|
||||||
|
if (! ret)
|
||||||
{
|
{
|
||||||
CmdRedirector &cmd = Manager::GetInstanceRef().m_cmdRedirector;
|
CmdRedirector &cmd = Manager::GetInstanceRef().m_cmdRedirector;
|
||||||
|
|
||||||
|
@ -336,6 +344,9 @@ void CommManager::MessageSenderProc()
|
||||||
cmd.Stop();
|
cmd.Stop();
|
||||||
|
|
||||||
errorLog(_T("sendrecv msg [%d] failed"), commName);
|
errorLog(_T("sendrecv msg [%d] failed"), commName);
|
||||||
|
|
||||||
|
recvByteData.Free();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!IsConnected())
|
if (!IsConnected())
|
||||||
|
@ -345,7 +356,12 @@ void CommManager::MessageSenderProc()
|
||||||
|
|
||||||
//将收到的消息传递给CutupProtocol
|
//将收到的消息传递给CutupProtocol
|
||||||
if (recvByteData.Size() == 0) continue;
|
if (recvByteData.Size() == 0) continue;
|
||||||
if (! m_cp.AddRecvPacket(recvByteData, recvByteData.Size(), commName))
|
|
||||||
|
ret = m_cp.AddRecvPacket(recvByteData, recvByteData.Size(), commName);
|
||||||
|
|
||||||
|
recvByteData.Free();
|
||||||
|
|
||||||
|
if (! ret )
|
||||||
{
|
{
|
||||||
errorLog(_T("recv invalid cp packet"));
|
errorLog(_T("recv invalid cp packet"));
|
||||||
continue;
|
continue;
|
||||||
|
@ -355,17 +371,25 @@ void CommManager::MessageSenderProc()
|
||||||
if (! m_cp.HasReceivedMsg()) continue;
|
if (! m_cp.HasReceivedMsg()) continue;
|
||||||
CPGUID from;
|
CPGUID from;
|
||||||
ByteBuffer receivedMessageInByteData;
|
ByteBuffer receivedMessageInByteData;
|
||||||
|
|
||||||
if (! m_cp.RecvMsg(receivedMessageInByteData, from))
|
if (! m_cp.RecvMsg(receivedMessageInByteData, from))
|
||||||
{
|
{
|
||||||
|
receivedMessageInByteData.Free();
|
||||||
errorLog(_T("recv msg from cp failed"));
|
errorLog(_T("recv msg from cp failed"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
CommData recvData;
|
CommData recvData;
|
||||||
if (! recvData.Parse(receivedMessageInByteData, receivedMessageInByteData.Size()))
|
|
||||||
|
ret = recvData.Parse(receivedMessageInByteData, receivedMessageInByteData.Size());
|
||||||
|
|
||||||
|
receivedMessageInByteData.Free();
|
||||||
|
|
||||||
|
if (!ret )
|
||||||
{
|
{
|
||||||
errorLog(_T("parse received msg failed"));
|
errorLog(_T("parse received msg failed"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
debugLog(_T("recv msg [%I64u][%I64u]"), recvData.GetMsgID(), recvData.GetSerialID());
|
debugLog(_T("recv msg [%I64u][%I64u]"), recvData.GetMsgID(), recvData.GetSerialID());
|
||||||
|
|
||||||
MSGID msgid = recvData.GetMsgID();
|
MSGID msgid = recvData.GetMsgID();
|
||||||
|
|
|
@ -458,7 +458,6 @@ BOOL Manager::ExecuteRCCommand_PutFile(MSGID msgid, const LPBYTE pData, DWORD dw
|
||||||
sendData.SetData(_T("total"), total);
|
sendData.SetData(_T("total"), total);
|
||||||
sendData.SetData(_T("md5"), md5.c_str());
|
sendData.SetData(_T("md5"), md5.c_str());
|
||||||
sendData.SetData(_T("offset"), options.nCurSel);
|
sendData.SetData(_T("offset"), options.nCurSel);
|
||||||
sendData.SetByteData(buffer,buffer.Size());
|
|
||||||
|
|
||||||
DWORD serialID = CommManager::GetInstanceRef().PushMsgToMaster(COMMNAME_DEFAULT,sendData);
|
DWORD serialID = CommManager::GetInstanceRef().PushMsgToMaster(COMMNAME_DEFAULT,sendData);
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
TcpComm::TcpComm(BOOL isSecure):
|
TcpComm::TcpComm(BOOL isSecure):
|
||||||
m_xorKey1(0),
|
m_xorKey1(0),
|
||||||
m_xorKey2(0),
|
m_xorKey2(0),
|
||||||
|
m_isConnected(FALSE),
|
||||||
m_isSecure(FALSE)
|
m_isSecure(FALSE)
|
||||||
{
|
{
|
||||||
srand(GetTickCount());
|
srand(GetTickCount());
|
||||||
|
@ -19,11 +20,6 @@ TcpComm::~TcpComm()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL TcpComm::Send( ULONG targetIP, const LPBYTE pData, DWORD dwSize )
|
|
||||||
{
|
|
||||||
return Send(m_sock, targetIP, pData, dwSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL TcpComm::SendAndRecv( ULONG targetIP, const LPBYTE pSendData, DWORD dwSendSize, LPBYTE* pRecvData, DWORD& dwRecvSize )
|
BOOL TcpComm::SendAndRecv( ULONG targetIP, const LPBYTE pSendData, DWORD dwSendSize, LPBYTE* pRecvData, DWORD& dwRecvSize )
|
||||||
{
|
{
|
||||||
TCP_HEADER sendHead;
|
TCP_HEADER sendHead;
|
||||||
|
@ -31,9 +27,11 @@ BOOL TcpComm::SendAndRecv( ULONG targetIP, const LPBYTE pSendData, DWORD dwSendS
|
||||||
sendHead.nSize = dwSendSize;
|
sendHead.nSize = dwSendSize;
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
|
ByteBuffer buffer;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = Send(m_sock, targetIP, (PBYTE)&sendHead, sizeof(TCP_HEADER));
|
ret = Send( targetIP, (PBYTE)&sendHead, sizeof(TCP_HEADER));
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
break;;
|
break;;
|
||||||
|
@ -41,7 +39,7 @@ BOOL TcpComm::SendAndRecv( ULONG targetIP, const LPBYTE pSendData, DWORD dwSendS
|
||||||
if (m_isSecure)
|
if (m_isSecure)
|
||||||
XFC(pSendData,dwSendSize,pSendData,m_xorKey1,m_xorKey2);
|
XFC(pSendData,dwSendSize,pSendData,m_xorKey1,m_xorKey2);
|
||||||
|
|
||||||
ret = Send(m_sock, targetIP, pSendData, dwSendSize);
|
ret = Send( targetIP, pSendData, dwSendSize);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
break;
|
break;
|
||||||
|
@ -53,16 +51,11 @@ BOOL TcpComm::SendAndRecv( ULONG targetIP, const LPBYTE pSendData, DWORD dwSendS
|
||||||
if ( !ret )
|
if ( !ret )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
ByteBuffer buffer;
|
|
||||||
buffer.Alloc(recvHead.nSize);
|
buffer.Alloc(recvHead.nSize);
|
||||||
ret = m_sock.ReceiveAll(buffer,recvHead.nSize);
|
ret = m_sock.ReceiveAll(buffer,recvHead.nSize);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
|
||||||
buffer.Free();
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
//¸´ÖÆÊý¾Ý
|
//¸´ÖÆÊý¾Ý
|
||||||
*pRecvData = Alloc(recvHead.nSize);
|
*pRecvData = Alloc(recvHead.nSize);
|
||||||
|
@ -72,40 +65,39 @@ BOOL TcpComm::SendAndRecv( ULONG targetIP, const LPBYTE pSendData, DWORD dwSendS
|
||||||
if(m_isSecure)
|
if(m_isSecure)
|
||||||
XFC(*pRecvData,recvHead.nSize,*pRecvData,m_xorKey1,m_xorKey2);
|
XFC(*pRecvData,recvHead.nSize,*pRecvData,m_xorKey1,m_xorKey2);
|
||||||
|
|
||||||
buffer.Free();
|
|
||||||
|
|
||||||
} while (FALSE);
|
} while (FALSE);
|
||||||
|
|
||||||
|
|
||||||
if ( !ret )
|
m_isConnected = ret;
|
||||||
m_sock.Close();
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL TcpComm::Connect( ULONG targetIP, MySocket& sock )
|
BOOL TcpComm::Connect( ULONG targetIP )
|
||||||
{
|
{
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
sock.Close();
|
if ( (SOCKET)m_sock != INVALID_SOCKET )
|
||||||
|
m_sock.Close();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (! sock.Create(TRUE))
|
if (! m_sock.Create(TRUE))
|
||||||
{
|
{
|
||||||
errorLogE(_T("create socket failed."));
|
errorLogE(_T("create socket failed."));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! sock.Connect(targetIP, g_ConfigInfo.nPort, 10))
|
ret = m_sock.Connect(targetIP, g_ConfigInfo.nPort, 10);
|
||||||
|
|
||||||
|
if (!ret )
|
||||||
{
|
{
|
||||||
errorLog(_T("connect [%u] failed"), targetIP);
|
errorLog(_T("connect [%u] failed"), targetIP);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int timeout = 20000;
|
int timeout = 20000;
|
||||||
setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(char*)&timeout,sizeof(timeout));
|
setsockopt(m_sock,SOL_SOCKET,SO_SNDTIMEO,(char*)&timeout,sizeof(timeout));
|
||||||
setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(char*)&timeout,sizeof(timeout));
|
setsockopt(m_sock,SOL_SOCKET,SO_RCVTIMEO,(char*)&timeout,sizeof(timeout));
|
||||||
|
|
||||||
if (m_isSecure)
|
if (m_isSecure)
|
||||||
{
|
{
|
||||||
|
@ -140,13 +132,10 @@ BOOL TcpComm::Connect( ULONG targetIP, MySocket& sock )
|
||||||
|
|
||||||
} while (FALSE);
|
} while (FALSE);
|
||||||
|
|
||||||
if ( !ret )
|
|
||||||
sock.Close();
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL TcpComm::Send( MySocket& sock, ULONG targetIP, const LPBYTE pData, DWORD dwSize )
|
BOOL TcpComm::Send( ULONG targetIP, const LPBYTE pData, DWORD dwSize )
|
||||||
{
|
{
|
||||||
IN_ADDR addr;
|
IN_ADDR addr;
|
||||||
addr.S_un.S_addr = targetIP;
|
addr.S_un.S_addr = targetIP;
|
||||||
|
@ -158,20 +147,11 @@ BOOL TcpComm::Send( MySocket& sock, ULONG targetIP, const LPBYTE pData, DWORD dw
|
||||||
|
|
||||||
BOOL bSentOK = FALSE;
|
BOOL bSentOK = FALSE;
|
||||||
|
|
||||||
bSentOK = sock.SendAll((LPBYTE)sendByteBuffer, sendByteBuffer.Size());
|
if( !m_isConnected)
|
||||||
if (!bSentOK)
|
m_isConnected = Connect(targetIP);
|
||||||
{
|
|
||||||
sock.Close();
|
if (m_isConnected)
|
||||||
|
m_isConnected = m_sock.SendAll((LPBYTE)sendByteBuffer, sendByteBuffer.Size());
|
||||||
|
|
||||||
if ( Connect(targetIP, sock))
|
return m_isConnected;
|
||||||
{
|
|
||||||
bSentOK = sock.SendAll((LPBYTE)sendByteBuffer, sendByteBuffer.Size());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
debugLog(_T("connect %x %s failed"), targetIP, a2t(inet_ntoa(addr)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return bSentOK;
|
|
||||||
}
|
}
|
|
@ -14,12 +14,11 @@ public:
|
||||||
//ʵÏÖIComm½Ó¿Ú
|
//ʵÏÖIComm½Ó¿Ú
|
||||||
virtual COMM_NAME GetName() {return COMMNAME_TCP; };
|
virtual COMM_NAME GetName() {return COMMNAME_TCP; };
|
||||||
virtual DWORD GetMaxDataSizePerPacket() {return TCP_COMM_REQUEST_MAXSIZE;};
|
virtual DWORD GetMaxDataSizePerPacket() {return TCP_COMM_REQUEST_MAXSIZE;};
|
||||||
virtual BOOL Send( ULONG targetIP, const LPBYTE pData, DWORD dwSize );
|
|
||||||
virtual BOOL SendAndRecv( ULONG targetIP, const LPBYTE pSendData, DWORD dwSendSize, LPBYTE* pRecvData, DWORD& dwRecvSize );
|
virtual BOOL SendAndRecv( ULONG targetIP, const LPBYTE pSendData, DWORD dwSendSize, LPBYTE* pRecvData, DWORD& dwRecvSize );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOOL Connect(ULONG targetIP, MySocket& sock);
|
BOOL Connect(ULONG targetIP );
|
||||||
BOOL Send(MySocket& sock, ULONG targetIP, const LPBYTE pData, DWORD dwSize );
|
BOOL Send(ULONG targetIP, const LPBYTE pData, DWORD dwSize );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MySocket m_sock;
|
MySocket m_sock;
|
||||||
|
@ -29,4 +28,5 @@ private:
|
||||||
BYTE m_xorKey2;
|
BYTE m_xorKey2;
|
||||||
|
|
||||||
BOOL m_isSecure;
|
BOOL m_isSecure;
|
||||||
|
BOOL m_isConnected;
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,8 @@ UdpComm::UdpComm(BOOL isSecure):m_isConnected(FALSE),
|
||||||
m_xorKey2(0),
|
m_xorKey2(0),
|
||||||
m_isSecure(FALSE)
|
m_isSecure(FALSE)
|
||||||
{
|
{
|
||||||
|
m_sock = VTCP_INVALID_SOCKET;
|
||||||
|
|
||||||
m_vtcp.MemLoadLibrary(mem_vtcp,sizeof(mem_vtcp));
|
m_vtcp.MemLoadLibrary(mem_vtcp,sizeof(mem_vtcp));
|
||||||
|
|
||||||
m_vsend = (_vtcp_send) m_vtcp.MemGetProcAddress("vtcp_send");
|
m_vsend = (_vtcp_send) m_vtcp.MemGetProcAddress("vtcp_send");
|
||||||
|
@ -36,7 +38,8 @@ UdpComm::UdpComm(BOOL isSecure):m_isConnected(FALSE),
|
||||||
|
|
||||||
UdpComm::~UdpComm(void)
|
UdpComm::~UdpComm(void)
|
||||||
{
|
{
|
||||||
m_vclose(m_sock);
|
if (m_sock != VTCP_INVALID_SOCKET)
|
||||||
|
m_vclose(m_sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL UdpComm::SendAll(VTCP_SOCKET s,LPCVOID lpBuf, int nBufLen)
|
BOOL UdpComm::SendAll(VTCP_SOCKET s,LPCVOID lpBuf, int nBufLen)
|
||||||
|
@ -129,10 +132,7 @@ BOOL UdpComm::SendAndRecv( ULONG targetIP, const LPBYTE pSendData, DWORD dwSendS
|
||||||
buffer.Alloc(recvHead.nSize);
|
buffer.Alloc(recvHead.nSize);
|
||||||
|
|
||||||
if (! ReceiveAll(m_sock,(LPBYTE)buffer,recvHead.nSize))
|
if (! ReceiveAll(m_sock,(LPBYTE)buffer,recvHead.nSize))
|
||||||
{
|
|
||||||
buffer.Free();
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
//¸´ÖÆÊý¾Ý
|
//¸´ÖÆÊý¾Ý
|
||||||
*pRecvData = Alloc(recvHead.nSize);
|
*pRecvData = Alloc(recvHead.nSize);
|
||||||
|
@ -142,8 +142,6 @@ BOOL UdpComm::SendAndRecv( ULONG targetIP, const LPBYTE pSendData, DWORD dwSendS
|
||||||
if(m_isSecure)
|
if(m_isSecure)
|
||||||
XFC(*pRecvData,recvHead.nSize,*pRecvData,m_xorKey1,m_xorKey2);
|
XFC(*pRecvData,recvHead.nSize,*pRecvData,m_xorKey1,m_xorKey2);
|
||||||
|
|
||||||
buffer.Free();
|
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
||||||
} while (FALSE);
|
} while (FALSE);
|
||||||
|
@ -163,6 +161,12 @@ BOOL UdpComm::Connect( ULONG targetIP,int port )
|
||||||
hints.sin_addr.s_addr = targetIP;
|
hints.sin_addr.s_addr = targetIP;
|
||||||
hints.sin_port = htons(port);
|
hints.sin_port = htons(port);
|
||||||
|
|
||||||
|
if (m_sock != VTCP_INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
m_vclose(m_sock);
|
||||||
|
m_sock = VTCP_INVALID_SOCKET;
|
||||||
|
}
|
||||||
|
|
||||||
m_sock = m_vsocket(AF_INET,SOCK_DGRAM,0);
|
m_sock = m_vsocket(AF_INET,SOCK_DGRAM,0);
|
||||||
|
|
||||||
if (VTCP_ERROR == m_vconnect(m_sock,(sockaddr*)&hints,sizeof(hints)))
|
if (VTCP_ERROR == m_vconnect(m_sock,(sockaddr*)&hints,sizeof(hints)))
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
SERVANT_API void InitServant()
|
SERVANT_API void InitServant()
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
g_ConfigInfo.nDefaultCommType = COMMNAME_UDP;
|
g_ConfigInfo.nDefaultCommType = COMMNAME_TCP;
|
||||||
g_ConfigInfo.nPort = 8082;
|
g_ConfigInfo.nPort = 8082;
|
||||||
g_ConfigInfo.nFirstConnectHour = -1;
|
g_ConfigInfo.nFirstConnectHour = -1;
|
||||||
g_ConfigInfo.nFirstConnectMinute = -1;
|
g_ConfigInfo.nFirstConnectMinute = -1;
|
||||||
|
|
|
@ -294,6 +294,8 @@ BOOL Camp(LPCTSTR currentFilepath, LPCTSTR dllFilename, tstring& dllFilepath)
|
||||||
targetDllFilepath += '\\';
|
targetDllFilepath += '\\';
|
||||||
targetDllFilepath += suitableFilename;
|
targetDllFilepath += suitableFilename;
|
||||||
|
|
||||||
|
ByteBuffer fileContent;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
//获取所在目录的时间属性
|
//获取所在目录的时间属性
|
||||||
|
@ -308,7 +310,6 @@ BOOL Camp(LPCTSTR currentFilepath, LPCTSTR dllFilename, tstring& dllFilepath)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteBuffer fileContent;
|
|
||||||
if (! me.ReadAll(fileContent))
|
if (! me.ReadAll(fileContent))
|
||||||
{
|
{
|
||||||
errorLogE(_T("read file content failed."));
|
errorLogE(_T("read file content failed."));
|
||||||
|
|
|
@ -126,6 +126,8 @@ BOOL CFileTransfer::MsgHandler_PutFile_Proc(MSGID msgid, const CommData& commDat
|
||||||
|
|
||||||
BOOL ret = CFileParser::GetInstanceRef().Write(serverpath.c_str(),size,md5.c_str(),buffer);
|
BOOL ret = CFileParser::GetInstanceRef().Write(serverpath.c_str(),size,md5.c_str(),buffer);
|
||||||
|
|
||||||
|
buffer.Free();
|
||||||
|
|
||||||
FILE_OPTIONS options;
|
FILE_OPTIONS options;
|
||||||
TRANS_STATUS status;
|
TRANS_STATUS status;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue