【发布时间】:2017-11-22 16:29:07
【问题描述】:
我通过 IdHTTP 组件创建了一个HTTP server,现在我想通过互联网访问它。我已经从一个文本文件中发布了一个字符串。
我可以通过以下方式访问它:
但是我如何通过互联网访问它?我试过http://[myexternalIPaddress]:80,但没有得到回复。
这是我的代码:
procedure TForm1.IdHTTPServer1CommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
myFile : TextFile;
text: String;
begin
AssignFile(myFile, 'C:\Users\xxx\Desktop\test.txt');
Reset(myFile);
ReadLn(myFile, text);
AResponseInfo.ContentText := text;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
IdHTTPServer1.Active := True;
end;
【问题讨论】:
-
您需要端口转发您的路由器。在路由器中打开端口 80(并允许防火墙中的连接)