F
fanzhaoli
Unregistered / Unconfirmed
GUEST, unregistred user!
我是个delphi的生手,想把客户端的请求完全转移到某一个IP中去,同时把这个IP的回应返回
给这个客户端。
下面是部分源码,我的问题是:由于客户端请求所产生的TWSocketClient和我生成的CliSocket: TWSocket
应该是一一对应的,但我在OnDataAvailable := ClientDataAvailable这个函数中如何获得
相应CliSocket;同样,在CliSocket的OnDataAvailable中如何得到相应的TWSocketClient?
procedure TTcpSrvForm.WSocketServer1ClientConnect(
Sender : TObject;
Client : TWSocketClient;
Error : Word);
var
CliSocket: TWSocket;
begin
//connect to fayhoo
CliSocket.Proto := 'tcp';
CliSocket.Port := '80';
CliSocket.Addr := 'www.sohu.com';
CliSocket.Connect;
{ Connect is asynchronous (non-blocking). We will wait while the }
{ session is connecting or application terminated. }
while CliSocket.State in [wsConnecting] do begin
Application.ProcessMessages;
if Application.Terminated then
Exit;
end;
// ShowMessage(inttostr(CliSocket.ComponentIndex );
with Client as TTcpSrvClient do begin
Display('Client connecting: ' + PeerAddr);
LineMode := TRUE;
LineEdit := TRUE;
OnDataAvailable := ClientDataAvailable;
OnBgException := ClientBgException;
ConnectTime := Now;
end;
end;
给这个客户端。
下面是部分源码,我的问题是:由于客户端请求所产生的TWSocketClient和我生成的CliSocket: TWSocket
应该是一一对应的,但我在OnDataAvailable := ClientDataAvailable这个函数中如何获得
相应CliSocket;同样,在CliSocket的OnDataAvailable中如何得到相应的TWSocketClient?
procedure TTcpSrvForm.WSocketServer1ClientConnect(
Sender : TObject;
Client : TWSocketClient;
Error : Word);
var
CliSocket: TWSocket;
begin
//connect to fayhoo
CliSocket.Proto := 'tcp';
CliSocket.Port := '80';
CliSocket.Addr := 'www.sohu.com';
CliSocket.Connect;
{ Connect is asynchronous (non-blocking). We will wait while the }
{ session is connecting or application terminated. }
while CliSocket.State in [wsConnecting] do begin
Application.ProcessMessages;
if Application.Terminated then
Exit;
end;
// ShowMessage(inttostr(CliSocket.ComponentIndex );
with Client as TTcpSrvClient do begin
Display('Client connecting: ' + PeerAddr);
LineMode := TRUE;
LineEdit := TRUE;
OnDataAvailable := ClientDataAvailable;
OnBgException := ClientBgException;
ConnectTime := Now;
end;
end;