On Oct 29, 2009, at 6:35 PM, colors wrote:

So before I try to communicate with the server, I would like to know that I can actually get off the machine to some kind of network. This will help avoid having to wait for curl to timeout. It looks like NSHost and SCNetwork... depend on having a specific address or domain. How can I just determine if there is a physical connection to a network?

This question doesn't really have a good answer. If I plug my Mac into an Ethernet hub, but the hub's not connected to anything else, is that a network? If I plug both ends of an Ethernet cable into two Macs (so they can connect to each other) is that a network? What about the similar case of a 'computer-to-computer' AirPort network? What about if the base station for my wireless network has lost its Ethernet connection, so I can see the ten other machines on that network but nothing else? What about a company intranet where it's not possible to reach the outside except via proxies?

At some point the answer starts to become "yes" for your app. But that point is different for different apps, and there's no clear dividing line. Generally the best you can do is determine a specific hostname or IP address you want to connect to, and see if it's possibly reachable.

If you need something more generic, you could use SC to check whether there's a DNS server available; that generally indicates that you're on some kind of nontrivial network (although it could be as vestigial as you and a disconnected NAT router.)

—Jens_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to