(1) When cut into the background, the network is already running.
(2) When WiFi is turned off, the network will already be running and the iOS system will not handle anything.
(3) When the screen is locked, the iOS system recycles the network resources used by the app.
From the network:
iphone is via WiFi or GPRS internet, then when the socket connection is idle for a period of time, the connection may be shut down by the router, in order to maintain the connection, we need to constantly send heartbeat packets.
Since the iphone program will be suspended after it has been cut into the background, the heartbeat packet cannot be sent regularly, so this problem can only be solved by the server. The common approach is for the server to send a heartbeat packet to each client at regular intervals to maintain the connection. Each time the client receives a heartbeat packet, the client wakes up with iOS, gets a short CPU time, and then enters the pending state again.
Network processing details for iOS