2 cxh194311 cxh194311 于 2017.01.11 16:02 提问

IdTCPServerExecute函数接受不到数据

void __fastcall TfrmMain::IdTCPServerExecute(TIdContext *AContext)
{
CoInitialize(NULL);
try

    TCommHead Head = RecvHead(AContext->Connection);
    TCommRequest Request = RecvRequest(AContext->Connection, Head);
    TCommAnswer Answer;
    Answer.Init();

switch (Head.CommType)
{
case cs_Comm_Request_OpenSQL:
{
TADOConnection *Connection = FPoolerMan->LockConnection(
AContext->Connection->Socket->Binding->Handle, Request.ConnectID);

            if ( Connection == NULL )
            {
                Answer.ErrorNo = -1;
                Answer.ErrorInfo = SERVER_IS_BUSY;

                SendAnswer(Head.CommType, Answer, AContext->Connection);
            }
            else
            {

                    Answer.ErrorNo = -1;
                    Answer.ErrorInfo = "无效的SQL";

                    SendAnswer(Head.CommType, Answer, AContext->Connection);

                    WriteLog("IP:" + AContext->Binding()->PeerIP + " " + Request.CommandText);

                }
            }

            break;
        }
        case cs_Comm_Request_OpenFunc:  // 执行功能,返回结果集
        {
            TADOConnection *Connection = FPoolerMan->LockConnection(
                AContext->Connection->Socket->Binding->Handle, Request.ConnectID);

            if ( Connection == NULL )
            {
                Answer.ErrorNo = -1;
                Answer.ErrorInfo = SERVER_IS_BUSY;

                SendAnswer(Head.CommType, Answer, AContext->Connection);
            }
            else
            {
                TMemoryStream *mm = new TMemoryStream();
                try
                {


                    SendAnswer(Head.CommType, Answer, AContext->Connection, mm);

                }
                __finally
                {}
            }

            break;
        }


        }
        default:
            ;
    }
}
__finally
{
    CoUninitialize;
}

}

1个回答

cxh194311
cxh194311   2017.01.11 16:03

如果客户端连接300个左右有时候就接受不到数据 大神求解

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!