它应该是您的开发机器中的东西,因为将 119 端口(或任何其他可用端口)与 INDY HTTP Server 一起使用是完全有效的。考虑到不建议在 1024 保留端口之下使用不同于 80 的端口,但这是另一回事。
我做了一个简单的测试,两个应用程序。以下是相关部分:
服务器
dfm
object Form2: TForm2
Caption = 'Server'
object IdHTTPServer1: TIdHTTPServer
Active = True
Bindings = <>
DefaultPort = 119
Left = 56
Top = 40
end
end
客户
dfm
object Form3: TForm3
Caption = 'Form3'
object Memo1: TMemo
Left = 16
Top = 8
Width = 185
Height = 89
Lines.Strings = (
'Memo1')
TabOrder = 0
end
object Button1: TButton
Left = 207
Top = 8
Width = 75
Height = 25
Caption = 'Connect'
TabOrder = 1
OnClick = Button1Click
end
object Button2: TButton
Left = 207
Top = 39
Width = 75
Height = 25
Caption = 'Disconnect'
TabOrder = 2
OnClick = Button2Click
end
object IdTCPClient1: TIdTCPClient
OnStatus = IdTCPClient1Status
ConnectTimeout = 0
Host = 'localhost'
IPVersion = Id_IPv4
Port = 119
ReadTimeout = -1
Left = 32
Top = 40
end
end
帕斯
procedure TForm3.Button1Click(Sender: TObject);
begin
IdTCPClient1.Connect;
end;
procedure TForm3.Button2Click(Sender: TObject);
begin
IdTCPClient1.Disconnect;
end;
procedure TForm3.IdTCPClient1Status(ASender: TObject; const AStatus: TIdStatus;
const AStatusText: string);
begin
Memo1.Lines.Add(AStatusText);
end;
结果:
不要忘记允许防火墙上的流量,例如通过接受默认的 windows 对话框(在使用 windows 防火墙的情况下):