Usually you should not try to test if connectivity is available because 1) it introduces a race condition between test and use 2) tests can be unreliable as xigoi pointed out 3) sending out spurious traffic is bad network citizenship 4) it introduces unnecessary complexity and delays.
Hovever, if you specifically need to trigger some activity based on the status of network interfaces it's difficult to do it in a very portable way but perhaps `getPrimaryIPAddr` might help.
