0

I have no clue what is causing this, but using a socket on iOS and calling connect() makes the app hang for 30s to 1 minute or more. And when it finally returns, half of the time the connection failed, even if the server is perfectly working.

I am using low level sockets, since I am avoid having objective C code at all. What could cause this?

4

1 回答 1

1

虽然这种行为是正常的,但您可以在连接之前将您的套接字设置为非阻塞,并且您将能够在等待它的同时做其他事情。

使用 select 来查看它是否可写,当它返回 true 时,连接已经完成(一种或另一种方式)。

有关如何检测连接是否成功的详细信息在这里

于 2013-08-10T21:41:58.697 回答