0

I'm implementing app functionality, that requires checking network reachability in a way such as: 1/ Send http request 2/ If it fails with specific kinds of error, plan to repeat request, when network is reachable 3/ When request completes successfully, fill the View's content

It is possible to use SCNetworkReachability or NWPathMonitor, but, as Apple informs, it may result in false negatives, and there is no way to deal with them.

The question is, why not to ping server multiple times instead? Likewise in Apple's SimplePing example? Is it a good approach?

Thank you.

Fedor
  • 13
  • 4
  • Better to simply retry the network operation. It will either succeed or fail. If it fails then wait longer and try again. Pinging or reachability just incur network overhead; – Paulw11 Oct 07 '21 at 11:11
  • Why not to implement the same thing with ping in order to save network resources? And then perform request – Fedor Oct 08 '21 at 03:21
  • Because implementing icmp ping is non trivial and just because ping is working doesn't mean that the server is working. You could have connectivity but the server has a problem and can't actually process the request. But sure, use ping if you like. It isn't just built-in though so you need to either find an external framework or write your own. – Paulw11 Oct 08 '21 at 03:31

0 Answers0