Fra*_*tic 14 delphi proxy networking indy delphi-2010
我是Indy的新手,我想用它构建一个简单的代理服务器.这是一个非常大的图书馆,我只是不知道从哪里开始.当客户端连接到服务器时,OnExucute将启动并接收客户端连接作为参数(AContext.Connection).
我想做以下事情:
[client connection] := AContext.Connection
read host/port from [client connection]
[remote connection] := connect to host/port
while both connections alive:
if data available in [client connection]:
read data from [client connection]
write data to [remote connection]
if data available in [remote connection]:
read data from [remote connection]
write data to [client connection]
Run Code Online (Sandbox Code Playgroud)
问题是我应该使用哪些功能?IOHandlerConnection对象中有属性,有大量的属性.请帮忙.
我正在使用随Delphi2010一起提供的Indy.
Rem*_*eau 20
Indy有自己的代理组件,可以满足您的要求.看看TIdMappedPortTCP和TIdHTTPProxyServer组件首发名额.
TIdMappedPortTCP是一种通用代理,只是来回传递原始数据.您可以使用其OnConnect事件为该连接动态配置目标主机/端口(例如通过从客户端读取),或者可以为所有连接静态设置其属性MappedHost和MappedPort属性.如果需要,您可以使用它OnExecute和OnOutboundData事件在数据通过代理时修改数据.
TIdHTTPProxyServer是一种专门代理仅适用于基于HTTP的代理,其中,所述客户端使用HTTP GET,POST,HEAD,和CONNECT动词,指定绝对URL到目标主机/端口,并且然后传递HTTP标头和数据来回根据需要(CONNECT通常用于通过防火墙代理SSL/TLS连接).
| 归档时间: |
|
| 查看次数: |
5881 次 |
| 最近记录: |