How to set timeout when pass a negative value to the third parameter of CFSocketConnectToAddress function?

In order to get the reason of connection fail from

kCFSocketConnectCallBack
, I must pass a negative number to
CFSocketConnectToAddress
's
timeout
parameter(like this:
CFSocketConnectToAddress(self.socket, sin_cfd, -1)
). But I also want to set connection timeout. Do you know how to set connection timeout in this case?

Replies

I’m helping itang in the context of [their other thread][thread] but, for those following along at home, the take-home message here is that you should not use CFSocket for networking.

https://forums.developer.apple.com/thread/114518

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"