Connect an iPhone application to a server on a offline network

I am developing a system that has a simple Java server on a private network without an Internet connection, a Wifi router that allows mobile devices to connect to the network and server, an iOS application that connects to the server using TCP. I found that when a non-network device (such as iPod touch) is connected to the network via a Wi-Fi router, it has no problem connecting to the server. However, when connecting an iPhone to a Wi-Fi access point, the client application on the device takes more than 5 minutes to find the server.

I believe that if there is no Internet connection, the device will use its cellular network to access the Internet. From one observation, after connecting to the access point, some online notifications were still pressed on the phone (I’m 100% sure that there was no Internet access in the network), but after a few minutes there was no more Internet access and the phone was able to connect to the server.

So the question is, how can I achieve instant communication with the server for the iPhone? Is there something that drives connected client devices to think that there is Internet access?

+6
source share
1 answer

Is there load balancing for the server?

Another option is that you can check your network or Wi-Fi connection if Wi-Fi is turned off and then display a prompt.

func isConnectedToNetwork() -> Bool { var zeroAddress = sockaddr_in(sin_len: 0, sin_family: 0, sin_port: 0, sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0)) zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress)) zeroAddress.sin_family = sa_family_t(AF_INET) let defaultRouteReachability = withUnsafePointer(&zeroAddress) { SCNetworkReachabilityCreateWithAddress(nil, UnsafePointer($0)).takeRetainedValue() } var flags: SCNetworkReachabilityFlags = 0 if SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags) == 0 { return false } let isReachable = (flags & UInt32(kSCNetworkFlagsReachable)) != 0 let needsConnection = (flags & UInt32(kSCNetworkFlagsConnectionRequired)) != 0 return (isReachable && !needsConnection) ? true : false } 
+1
source

All Articles