delphi – 使用Indy的代理服务器

我是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]

问题是我应该使用哪些功能? Connection对象中有IOHandler属性,其中有吨.请帮忙.

我用Indy搭配Delphi2010.

解决方法

Indy有自己的代理组件来做你所要求的.看看TIdMappedPortTCP和TIdHTTPProxyServer组件作为起始位置.

TIdMappedPortTCP是一种通用代理,它只是传递原始数据.您可以使用其OnConnect事件来动态配置该连接的目标主机/端口(例如通过从客户端读取),或者可以静态地为所有连接设置其MappedHost和MappedPort属性.如果需要,您可以使用其OnExecute和OnOutboundData事件来修改数据.

TIdHTTPProxyServer仅用于基于HTTP的代理,其中客户端使用HTTP GET,POST,HEAD和CONNECT动词,为目标主机/端口指定绝对URL,然后根据需要来回传递HTTP头和数据(CONNECT通常用于通过防火墙代理SSL / TLS连接).

相关文章

 从网上看到《Delphi API HOOK完全说明》这篇文章,基本上都...
  从网上看到《Delphi API HOOK完全说明》这篇文章,基本上...
ffmpeg 是一套强大的开源的多媒体库 一般都是用 c/c+&#x...
32位CPU所含有的寄存器有:4个数据寄存器(EAX、EBX、ECX和ED...
1 mov dst, src dst是目的操作数,src是源操作数,指令实现的...