procedure TRunSocket.ExecGateBuffers(nGateIndex:Integer;Gate:pTGateInfo;Buffer:PChar;nMsgLen:Integer);
var
nLen:Integer;
Buff:PChar;
MsgBuff:PChar;
MsgHeader:pTMsgHeader; //0x20
nCheckMsgLen:Integer;
TempBuff:PChar;
ResourceString
sExceptionMsg1 = '[Exception] TRunSocket::ExecGateBuffers -> pBuffer';
[B][COLOR=#ff0000]sExceptionMsg2 = '[Exception] TRunSocket::ExecGateBuffers -> @pwork,ExecGateMsg ';[/COLOR][/B]
sExceptionMsg3 = '[Exception] TRunSocket::ExecGateBuffers -> FreeMem';
begin
nLen:=0;
Buff:=nil;
try
if Buffer <> nil then begin
ReallocMem(Gate.Buffer,Gate.nBuffLen + nMsgLen);
Move(Buffer^,Gate.Buffer[Gate.nBuffLen],nMsgLen);
end;
except
MainOutMessage(sExceptionMsg1);
end;
[B][COLOR=#0000ff]try[/COLOR][/B]
nLen:=Gate.nBuffLen + nMsgLen;
Buff:=Gate.Buffer;
if nLen >= SizeOf(TMsgHeader) then begin
while (True) do begin
{
pMsg:=pTMsgHeader(Buff);
if pMsg.dwCode = RUNGATECODE then begin
if nLen < (pMsg.nLength + SizeOf(TMsgHeader)) then break;
MsgBuff:=@Buff[SizeOf(TMsgHeader)];
}
MsgHeader:=pTMsgHeader(Buff);
nCheckMsgLen:=abs(MsgHeader.nLength) + SizeOf(TMsgHeader);
if (MsgHeader.dwCode = RUNGATECODE) and (nCheckMsgLen < $8000) then begin
if nLen < nCheckMsgLen then break;
MsgBuff:=Buff + SizeOf(TMsgHeader);//Jacky 1009 »»ÉÏ
//MsgBuff:=@Buff[SizeOf(TMsgHeader)];
ExecGateMsg(nGateIndex,Gate,MsgHeader,MsgBuff,MsgHeader.nLength);
Buff:=Buff + SizeOf(TMsgHeader) + MsgHeader.nLength;//Jacky 1009 »»ÉÏ
//Buff:=@Buff[SizeOf(TMsgHeader) + pMsg.nLength];
nLen:= nLen - (MsgHeader.nLength + SizeOf(TMsgHeader));
end else begin
Inc(Buff);
Dec(nLen);
end;
if nLen < SizeOf(TMsgHeader) then break;
end;
end;
[COLOR=#0000ff][B]except[/B][/COLOR]
[COLOR=#ff0000][B] MainOutMessage(sExceptionMsg2);[/B][/COLOR]