E
enjaylow
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TfrmServerMain.ServerSocketClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
var
i,j:integer;
begin
j:=-1;
for i:=0 to sessions do
begin
if not session.CUsed then
begin
session.CHandle := Socket.SocketHandle ;//客户端套接字句柄
[red]上面这一句,这个socket.socketHandle表示的是什么意思啊?如果是代表客户端的socket句柄的话,那socket这个参数就代表了clientsocket了,但是下面那句session.CName:=Socket.RemoteHost;这个socket用了RemoteHost,代表socket是本地的socket啊,也就是serversocket,到这里我就搞不懂了,哪位大侠赐教一下啊~~ [/red]
session.CSocket := Socket;
session.CName := Socket.RemoteHost ;
session.CAddress := Socket.RemoteAddress ;
session.CUsed := True;
Break;
end;
j:=i;
end;
if j=sessions then
begin
inc(sessions);
session[j].CHandle := Socket.SocketHandle ;
session[j].CSocket := Socket;
session[j].CName := Socket.RemoteHost ;
session[j].CAddress := Socket.RemoteAddress ;
session[j].CUsed := True;
end;
StatusBar.Panels[0].Text := '客户端 '+Socket.RemoteHost + ' 已经连接';
end;
Socket: TCustomWinSocket);
var
i,j:integer;
begin
j:=-1;
for i:=0 to sessions do
begin
if not session.CUsed then
begin
session.CHandle := Socket.SocketHandle ;//客户端套接字句柄
[red]上面这一句,这个socket.socketHandle表示的是什么意思啊?如果是代表客户端的socket句柄的话,那socket这个参数就代表了clientsocket了,但是下面那句session.CName:=Socket.RemoteHost;这个socket用了RemoteHost,代表socket是本地的socket啊,也就是serversocket,到这里我就搞不懂了,哪位大侠赐教一下啊~~ [/red]
session.CSocket := Socket;
session.CName := Socket.RemoteHost ;
session.CAddress := Socket.RemoteAddress ;
session.CUsed := True;
Break;
end;
j:=i;
end;
if j=sessions then
begin
inc(sessions);
session[j].CHandle := Socket.SocketHandle ;
session[j].CSocket := Socket;
session[j].CName := Socket.RemoteHost ;
session[j].CAddress := Socket.RemoteAddress ;
session[j].CUsed := True;
end;
StatusBar.Panels[0].Text := '客户端 '+Socket.RemoteHost + ' 已经连接';
end;