1

I am writing a multi-platform application that is a sort of 'proxy', designed to field HTTP requests and pass some of them to a remote server and respond to others directly. So it acts as both an HTTP client and an HTTP server.

I have been using the Indy 10 components in both Delphi and Lazarus, and they work well on desktop platforms. I have ported the project successfully to Windows, Linux, and MacOS using Lazarus. Now I am attempting to do the same to iOS, using Delphi XE4. I am currently running the project in the iOS Simulator on a Mac running OSX 10.8.2; later I will be targeting an iPad device.

But I'm finding that I can't get the TIdHTTPServer component to create a connection to an incoming request on iOS. I bind the server to an IP address and port and activate it; this starts the listener thread. But when I try to send a GET request to the server it raises the exception EIdIPVersionUnsupported, with the message "The requested IPVersion / Address family is not supported." This error happens whether I try to route the GET request from within the application itself, or externally from a browser running on another machine.

I normally bind the HTTP Server to the localhost IP address, as the proxy is intended to run as a background process fielding requests from the browser running in the foreground. For the external browser test, I bound it instead to the Mac's own IP address.

4

1 回答 1

3

大多数 Indy 组件,包括TIdHTTPServer,在 iOS 中的工作方式与在其他平台上的工作方式完全相同。Indy 中唯一改变以支持 iOS 的是实现低级套接字 API 函数调用(通过TIdStackVCLPosix类),并更新 Indy 的内部编码以支持新的 Embarcadero 移动编译器(ARC 等)。

TIdHTTPServer应该可以在 iOS 上运行,只要它有权打开 TCP/IP 侦听套接字。异常EIdIPVersionUnsupported意味着尝试使用TIdStackVCLPosix不支持该特定 API 调用的 IP 版本进行低级套接字 API 调用。所有TIdStackVCLPosix方法都支持 IPv4 和 IPv6。因此,在没有看到导致异常的实际堆栈跟踪的情况下,我只能猜测 Posix 的accept()函数可能报告连接的客户端正在使用 IPv4 或 IPv6 以外的套接字地址类型。

话虽如此,我只是修复了一个小错误,TIdStackVCLPosix.Accept()即在调用 POSIX 函数之前它没有初始化其地址存储的大小accept(),因此这可能是也可能不是促成因素。获取最新的 Indy 10 SVN 版本(其中包含未包含在 XE4 版本中的其他错误修复)并重试。

于 2013-05-02T00:41:20.890 回答