I want to provide my user with some meaningful error messages when network requests fail.
On Windows I can call InternetGetConnectedState() to see if there is an active network connection. What is the OS X equivalent?
Bonus points for example code if it’s complex.
Don’t look for an active network connection, look for your target host being reachable. It’s not complex, so no example code 🙂
Update: I think I should have explained what reachable means in this context. As described in the docs, a remote network address is considered reachable if a packet destined for that address could leave this computer via any network interface. This is, roughly speaking, an expression of the fact that the i/f is configured and able to either directly deliver to the remote system, or has a route available to get to it. Reachability doesn’t describe anything relating to whether the remote host is ‘up’ or whether the network between this computer and the remote one is functioning properly.