Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Mar : Re: about idTcpServer
| Subject: | Re: about idTcpServer |
| Posted by: | "darnis" (darn..@21cn.com) |
| Date: | Wed, 29 Mar 2006 19:51:58 |
OnExecute code:
procedure TfrmProxyMain.tcpServerExecute(AContext: TIdContext);
var
strTmp, str1: string;
iRec: integer;
oData: OleVariant;
ra: TlbResponseAsk;
p: TlbParameterMana;
begin
////
try
if AContext.Connection.Socket.Readable(1000) then
begin
p := TlbParameterMana.Create;
try
if DEBUG then
_('DA');
SetLength(strTmp, FPacketSize);
iRec := AContext.Connection.Socket.Binding.Receive(TBytes(strTmp));
if DEBUG then
_(Format('DL:%d, [%s]', [iRec, strTmp]));
if iRec <= 0 then begin
if cm.qData(Pointer(AContext)) then
AContext.Connection.Tag := integer(cm.CurrentHost);
// tcpServer.Scheduler.TerminateYarn(AContext.Yarn);
sleep(0);
exit;
end;
SetLength(strTmp, iRec);
DP.UnPacketData(strTmp, oData);
FTCPMsg.XML := oData;
if FTCPMsg.IsEmpty then begin
if DEBUG then
_(Format('EP:[%s]', [strTmp]));
sleep(0);
exit;
end;
p.Add('host', AContext.Connection.Socket.Binding.PeerIP);
p.Add('port', AContext.Connection.Socket.Binding.PeerPort);
p.Add('local', ltInner);
p.Add('thread', integer(Pointer(AContext)));
p.Add('packet', strTmp);
FTcpDispatcher[byte(FTcpMsg.PacketType)](FTcpMsg, p);
finally
p.Free;
end;
end;
except
on e: Exception do
begin
PutMessage(Format('%s %s', [str1, e.Message]));
// tcpServer.Scheduler.TerminateYarn(AContext.Yarn);
end;
end;
end;