【发布时间】:2016-04-13 17:53:34
【问题描述】:
我正在寻求帮助,几天后我的 tcpserver 接受了连接。或多或少总是在 1400 个连接中。 我使用一个类(TObject)来注册连接并在客户端断开连接但显然总是卡住连接时销毁。
Type
TSimpleClient = class(TObject)
IP : ShortString;
Connection : TidTCPServerConnection;
Deteccao : ShortString;
Existe : ShortString;
Contagem : Integer;
Bloqueado : ShortString;
Serial : ShortString;
Thread : Pointer;
end;
没有onconnect faço o seguinte:
Client := TSimpleClient.Create;
Client.IP := AThread.Connection.Socket.Binding.PeerIP;
Client.Thread := AThread;
Client.Serial := Received;
Client.Connection := AThread.Connection;
AThread.Data := Client;
没有断开连接:
Client := Pointer(AThread.Data);
IP := Client.IP;
Serial := Client.Serial;
try
Client.Free;
finally
AThread.Data := nil;
end;
我使用记录来存储和释放连接,但总是遇到连接卡住和服务器接收连接的问题。
更新:我的执行很简单。像这样:
Client := Pointer(AThread.Data);
try
Received := AThread.Connection.ReadLn;
Received := Protege('D', Received);
A := TStringList.Create;
Split('=', Received, A);
if A[0] = 'teste' then begin
//...
end;
A.Free;
except
on e: Exception do begin
AThread.Connection.Disconnect;
end;
end;
【问题讨论】:
标签: delphi indy connection tcpserver