IdTCPServer CPU占用率高,只要客户端连接上,占用率就90%左右,断开马上降下来, 用什么办法解决?
原来以为是我程序的问题,后来我做一个简单的示例程序,也是这样
//连接
procedure TForm1.IdTCPServer1Connect(AContext: TIdContext);
begin
Memo1.Lines.Add('客户端连接成功');
end;
//处理客户瑞发送信息
procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
var s :string;
begin
s := AContext.Connection.Socket.InputBufferAsString;
if s <> '' then
Memo1.Lines.Add('客户端信息:' + s);
end;
//断开连接
procedure TForm1.IdTCPServer1Disconnect(AContext: TIdContext);
begin
AContext.Connection.IOHandler.InputBuffer.Clear;
IdTCPServer1.Contexts.LockList.Remove(AContext);
IdTCPServer1.Contexts.UnlockList;
AContext.Data := nil;
Memo1.Lines.Add('客户端断开连接');
end;
[解决办法]
IdTCPServer好象可是设置工作模式,楼主可以看看