关于TCP/IP控件的使用方法,高手给给提示! ( 积分: 100 )

  • 主题发起人 主题发起人 lfj125
  • 开始时间 开始时间
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)在就出不去了(绝对确定),实在是能力有限,各位高手给个解法!
 
我在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)在就出不去了(绝对确定),实在是能力有限,各位高手给个解法!
 
http://www.projectindy.org/DemoDownloads/Indy9Demos_26Oct04.zip
 
后退
顶部