小
小胡1
Unregistered / Unconfirmed
GUEST, unregistred user!
我在Indy的例子中(/IndyDemos/IdTCPDemo/server.dpr)中看到如下的语句。
procedure Tform1.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;
AThread.Data:=TObject(NewClient);
try
Clients.LockList.Add(NewClient);
finally
Clients.UnlockList;
end;
Protocol.Lines.Add(TimeToStr(Time)+' Connection from "'+NewClient.DNS+'"');
end;
按照这个代码来看,"NewClient.DNS := AThread.Connection.LocalName;"
这句,似乎是要保存Client的计算机名的,我是根据下边"Connection from ...."
来猜测的。 如果AThread.Connection.LocalName不能返回Client的计算机名,
那它返回本机的计算机名有什么用呢?
procedure Tform1.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;
AThread.Data:=TObject(NewClient);
try
Clients.LockList.Add(NewClient);
finally
Clients.UnlockList;
end;
Protocol.Lines.Add(TimeToStr(Time)+' Connection from "'+NewClient.DNS+'"');
end;
按照这个代码来看,"NewClient.DNS := AThread.Connection.LocalName;"
这句,似乎是要保存Client的计算机名的,我是根据下边"Connection from ...."
来猜测的。 如果AThread.Connection.LocalName不能返回Client的计算机名,
那它返回本机的计算机名有什么用呢?