|
@@ -773,29 +773,34 @@ void CIOCPModel::_RecvProcess(PER_SOCKET_CONTEXT* pSocketContext, PER_IO_CONTEXT
|
|
|
ProHeader* phead = NULL;
|
|
|
if (pSocketContext->lastData.size() == 0)
|
|
|
{
|
|
|
+ // 꼇璃관庫;
|
|
|
if (PAK_LEN > pIoContext->m_Overlapped.InternalHigh)
|
|
|
{
|
|
|
+ OutputDebugString("A:꼇璃관庫;\n");
|
|
|
pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, pIoContext->m_Overlapped.InternalHigh);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
phead = (ProHeader*)pIoContext->m_wsaBuf.buf;
|
|
|
|
|
|
- // 供냥돨관;
|
|
|
+ // 供憐돨관;
|
|
|
if (phead->len == pIoContext->m_Overlapped.InternalHigh)
|
|
|
{
|
|
|
+ OutputDebugString("A:供憐돨관;\n");
|
|
|
_DeviceProc(pIoContext, (Package*)pIoContext->m_wsaBuf.buf);
|
|
|
}
|
|
|
// 鬼관;
|
|
|
else if (phead->len > pIoContext->m_Overlapped.InternalHigh)
|
|
|
{
|
|
|
+ OutputDebugString("A:鬼관;\n");
|
|
|
pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, pIoContext->m_Overlapped.InternalHigh);
|
|
|
}
|
|
|
// 낚관;
|
|
|
else if (phead->len < pIoContext->m_Overlapped.InternalHigh)
|
|
|
{
|
|
|
- _DeviceProc(pIoContext, (Package*)pIoContext->m_wsaBuf.buf);
|
|
|
+ OutputDebugString("A:낚관;\n");
|
|
|
pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf + phead->len, pIoContext->m_Overlapped.InternalHigh - phead->len);
|
|
|
+ _DeviceProc(pIoContext, (Package*)pIoContext->m_wsaBuf.buf);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -807,47 +812,66 @@ void CIOCPModel::_RecvProcess(PER_SOCKET_CONTEXT* pSocketContext, PER_IO_CONTEXT
|
|
|
phead = (ProHeader*)pSocketContext->lastData.data();
|
|
|
if (phead->len <= pSocketContext->lastData.size() + pIoContext->m_Overlapped.InternalHigh)
|
|
|
{
|
|
|
- lastlen = pSocketContext->lastData.size() + pIoContext->m_Overlapped.InternalHigh - phead->len;
|
|
|
- pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, pIoContext->m_Overlapped.InternalHigh - lastlen);
|
|
|
- // 供憐관;
|
|
|
- _DeviceProc(pIoContext, (Package*)pSocketContext->lastData.data());
|
|
|
- // 假岱관;
|
|
|
- pSocketContext->lastData.clear();
|
|
|
- if (lastlen)
|
|
|
- pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf + pIoContext->m_Overlapped.InternalHigh - lastlen, lastlen);
|
|
|
+ if ( phead->len <= pSocketContext->lastData.size() )
|
|
|
+ {
|
|
|
+ OutputDebugString("C:낚관;\n");
|
|
|
+ lastlen = pSocketContext->lastData.size() + pIoContext->m_Overlapped.InternalHigh - phead->len;
|
|
|
+ pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, pIoContext->m_Overlapped.InternalHigh - lastlen);
|
|
|
+ // 供憐관;
|
|
|
+ _DeviceProc(pIoContext, (Package*)pSocketContext->lastData.data());
|
|
|
+ // 假岱관;
|
|
|
+ pSocketContext->lastData.clear();
|
|
|
+ if (lastlen)
|
|
|
+ pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf + pIoContext->m_Overlapped.InternalHigh - lastlen, lastlen);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ OutputDebugString("C:휄꼇璃寧몸관;\n");
|
|
|
pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, pIoContext->m_Overlapped.InternalHigh);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ // 관庫假岱낀똑;
|
|
|
int diflen = PAK_LEN - pSocketContext->lastData.size();
|
|
|
+ // 휄꼇璃寧몸관庫;
|
|
|
if ( diflen > pIoContext->m_Overlapped.InternalHigh )
|
|
|
{
|
|
|
+ OutputDebugString("B:휄꼇璃寧몸관庫;\n");
|
|
|
pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, pIoContext->m_Overlapped.InternalHigh);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ // 틈냥供憐관庫;
|
|
|
pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, diflen);
|
|
|
phead = (ProHeader*)pSocketContext->lastData.data();
|
|
|
+
|
|
|
// 供憐관;
|
|
|
if ( phead->len == PAK_LEN + pIoContext->m_Overlapped.InternalHigh - diflen )
|
|
|
{
|
|
|
- _DeviceProc(pIoContext, (Package*)pIoContext->m_wsaBuf.buf);
|
|
|
+ OutputDebugString("B:供憐관;\n");
|
|
|
+ pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf + diflen, pIoContext->m_Overlapped.InternalHigh - diflen);
|
|
|
+ _DeviceProc(pIoContext, (Package*)pSocketContext->lastData.data());
|
|
|
+ pSocketContext->lastData.clear();
|
|
|
}
|
|
|
// 鬼관;
|
|
|
else if ( phead->len > PAK_LEN + pIoContext->m_Overlapped.InternalHigh - diflen)
|
|
|
{
|
|
|
+ OutputDebugString("B:鬼관;\n");
|
|
|
pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf + diflen, pIoContext->m_Overlapped.InternalHigh - diflen);
|
|
|
}
|
|
|
// 낚관;
|
|
|
else if (phead->len < PAK_LEN + pIoContext->m_Overlapped.InternalHigh - diflen)
|
|
|
{
|
|
|
+ OutputDebugString("B:낚관;\n");
|
|
|
// 莉供냥관;
|
|
|
pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf + diflen, phead->len - PAK_LEN);
|
|
|
- _DeviceProc(pIoContext, (Package*)pIoContext->m_wsaBuf.buf);
|
|
|
+ _DeviceProc(pIoContext, (Package*)pSocketContext->lastData.data());
|
|
|
pSocketContext->lastData.clear();
|
|
|
int last = pIoContext->m_Overlapped.InternalHigh - diflen - phead->len + PAK_LEN;
|
|
|
if (last)
|
|
@@ -906,16 +930,16 @@ void CIOCPModel::_DeviceProc(PER_IO_CONTEXT* pIoContext, Package* pak)
|
|
|
|
|
|
char* pjdata = cJSON_Print(pJson);
|
|
|
|
|
|
- Package reponse_pak;
|
|
|
- reponse_pak.header.version = 0xAB;
|
|
|
- reponse_pak.header.len = strlen(pjdata) + PAK_LEN;
|
|
|
- reponse_pak.buf = new byte[strlen(pjdata)];
|
|
|
- memcpy(reponse_pak.buf, pjdata, strlen(pjdata));
|
|
|
- if ( pjdata)
|
|
|
+ byte* sdata = new byte[strlen(pjdata) + PAK_LEN];
|
|
|
+ Package* reponse_pak = (Package*)sdata;
|
|
|
+ reponse_pak->header.version = 0xAB;
|
|
|
+ reponse_pak->header.len = strlen(pjdata) + PAK_LEN;
|
|
|
+ memcpy(reponse_pak->buf, pjdata, strlen(pjdata));
|
|
|
+ if (pjdata)
|
|
|
free(pjdata);
|
|
|
|
|
|
- int ret = send(pIoContext->m_sockAccept, (const char*)&reponse_pak, reponse_pak.header.len, 0);
|
|
|
- delete[]reponse_pak.buf;
|
|
|
+ int ret = send(pIoContext->m_sockAccept, (const char*)sdata, reponse_pak->header.len, 0);
|
|
|
+ delete[]sdata;
|
|
|
if ( ret == -1 )
|
|
|
{
|
|
|
DWORD dwEr = GetLastError();
|