我遇到了这个令人难以置信的疯狂错误!我将 idhttpserver,webbrowser 放到一个新的移动 android 应用程序上。
我希望服务器向浏览器提供内容。它在 Windows 上运行良好,但在我的 android 设备上失败。我测试了一个 tcpserver 和 tcpclient。我可以让客户端连接,但是当我启动 writeln 和 readln 时出现分段错误。
即使我在调试应用程序的情况下运行仍然崩溃......这是代码片段。
procedure TForm37.Button1Click(Sender: TObject);
begin
IdHTTPServer1.Bindings.Add;
try
IdHTTPServer1.Active := true;
if IdHTTPServer1.Active then
Button1.Text := 'Server Started';
except on E: Exception do
Button1.Text := 'Server Failed';
end;
end;
procedure TForm37.Button2Click(Sender: TObject);
var
astring : string;
begin
try
astring := IdHTTP1.Get('http://10.0.1.78:6000/');
// or astring := IdHTTP1.Get('http://127.0.0.1:6000/');
ShowMessage(astring);
except on E: Exception do
Button2.Text := 'connection failed';
end;
end;
procedure TForm37.IdHTTPServer1CommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
begin
AResponseInfo.ContentText :=
'<html><head><title>My First Response</title></head>' +
'<body>Command: ' + ARequestInfo.Command +
'<br />Host: ' + ARequestInfo.Host +
'<br />URI: ' + ARequestInfo.URI +
'<br />UserAgent: ' + ARequestInfo.UserAgent +
'</body></html>';
end;