Search code examples
iphonesocketsconnectionstandby

server can't close socket connection with iPhone when iPhone is in standby mode


I use AsyncSocket to establish tcp connection via Wifi to a server, and after 10 seconds, the server will actively close the connection.

When the iPhone is not in standby mode, the connection will be destroyed immediately after the server call ::close(int socked).

But when the iPhone is in standby mode, I find the connection is still alive when the server has called the ::close(int socketfd) API.

Can anyone give an explanation?


Solution

  • The Problem is that your server send the close question and wait for a answer of the client that it even will close the connection. Your IPhone is in Standby and can't send any question or answers, if the connection is dead it should be auto close, maybe you have to implement a connection dead function for this case.