如何在delphi中监听和重新映射tcp连接?

时间:2014-01-23 12:52:35

标签: delphi sockets tcp dns delphi-xe3

我有一个通过socks4-5连接的TCP连接(代理),并通过它发送http / https / DNS流量。 我需要分享一些东西,http / https等等通过tcp连接1和dns解析通过tcp连接2

enter image description here

我试图创建IdTCPServer1(但我不确定在正确的轨道上),它连接但没有发送给他。 此外,他一直坚持,直到ReadLn它不会被记录数据,这是不允许的。

procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
var str_str:String;
begin
  str_str:=AContext.Connection.Socket.ReadLn();
  if(str_str<>'') then    Memo1.Lines.Add('#TCP_SERVER: EXECUTE: '+str_str);

1 个答案:

答案 0 :(得分:0)

您需要处理(实施)socks4 / 5服务器端协议(请参阅http://tools.ietf.org/rfc/rfc1928.txt)。在请求中,您可以截取端口号以查看它是否为http,dns或其他。然后根据它转发连接。