Search code examples
iosdelphiwebsocketcross-platformindy

What is FIONBIO value for iOS, to Block/Unblock Sockets?


I've been working with the cross-platform Websocket client, based on the Indy TIdHTTP component, found here.

The client, TIdHTTPWebSocketClient, internally uses TIdWebSocketMultiReadThread; the latter creates a non-blocking socket (InitSpecialEventSocket method) by using Indy's GStack IOControl to access ioctl.

The code, downloaded from github, works for Windows, but failed on Android; FIONBIO had to be changed to $5421.

I'm currently unable to test on iOS, and wish to know if others have managed to get TIdHTTPWebSocketClient to work on this platform, and what value of FIONBIO should be used.

Thanks in advance.


Solution

  • FIONBIO applies to ioctlsocket() on Windows and ioctl() on POSIX.

    On POSIX, you can alternatively specify the SOCK_NONBLOCK flag when creating a socket, or set the O_NONBLOCK flag on a socket using fcntl(F_SETFL).

    Note that Indy does have an AOverlapped (non-blocking) parameter on the TIdStack.NewSocketHandle() and TIdStackBSDBase.WSSocket() methods, and a TIdStackBSDBase.SetBlocking() method, but they are not currently implemented for non-Windows platforms (code has been written for them, but has not been checked in).