L
lfj125
Unregistered / Unconfirmed
GUEST, unregistred user!
我在TcpServer的OnConnect事件里这样写:
procedure TChild_MangeFrm.ServerConnect(AThread: TIdPeerThread);
var
NewClient: PClient;
begin
GetMem(NewClient, SizeOf(TClient));
NewClient.DNS := AThread.Connection.LocalName;
NewClient.Connected := Now;
NewClient.LastAction := NewClient.Connected;
NewClient.Thread := AThread;
Protocol.Lines.Add(TimeToStr(Time)+' Connection from "'+NewClient.DNS+'"');
AThread.Data:=TObject(NewClient);
try
Clients.LockList.Add(NewClient);
finally
Clients.UnlockList;
end;
end;
其中:
PClient = ^TClient;
TClient = record
DNS : String[20];
Connected,LastAction : TDateTime;
Thread : Pointer;
UserID : String[20];
end;
Clients : TThreadList;
问题:
程序弟一次执行可以通过,可是第二次和以后执行到 Clients.LockList.Add(NewClient)在就出不去了(绝对确定),实在是能力有限,各位高手给个解法!
procedure TChild_MangeFrm.ServerConnect(AThread: TIdPeerThread);
var
NewClient: PClient;
begin
GetMem(NewClient, SizeOf(TClient));
NewClient.DNS := AThread.Connection.LocalName;
NewClient.Connected := Now;
NewClient.LastAction := NewClient.Connected;
NewClient.Thread := AThread;
Protocol.Lines.Add(TimeToStr(Time)+' Connection from "'+NewClient.DNS+'"');
AThread.Data:=TObject(NewClient);
try
Clients.LockList.Add(NewClient);
finally
Clients.UnlockList;
end;
end;
其中:
PClient = ^TClient;
TClient = record
DNS : String[20];
Connected,LastAction : TDateTime;
Thread : Pointer;
UserID : String[20];
end;
Clients : TThreadList;
问题:
程序弟一次执行可以通过,可是第二次和以后执行到 Clients.LockList.Add(NewClient)在就出不去了(绝对确定),实在是能力有限,各位高手给个解法!