• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Detecting network disconnected
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting network disconnected


  • Subject: Re: Detecting network disconnected
  • From: Joshua Graessley <email@hidden>
  • Date: Thu, 29 May 2003 13:32:22 -0700

On Thursday, May 29, 2003, at 10:49, Justin C. Walker wrote:

On Thursday, May 29, 2003, at 10:04 AM, Larry Gerndt wrote:

When using BSD sockets, what's the right way of detecting that the user has
disconnected his Mac from the network (i.e. pulled the plug)?

The correct mechanism is SystemConfiguration Framework. You can look at the scutil code to see examples of how to detect that a network interface has gone inactive.

A lower-layer mechanism is available, but you would have to do a lot of filtering and processing to be sure that the event you caught is the one you want. The SystemConfiguration framework source shows how to do that.

You may want to try something a little higher. I believe there are "reachability" APIs that let you specify a name or address that you'd like to connect to and determine if there is a chance it might be possible to connect to that address. This API is usually used before initiating a connection, but it might be possible to do something like check with the API any time the SystemConfiguration framework indicates something changed. I think that a future API will let you monitor the "reachability" of a remote name or address given a local address.

The reachability API can not indicate for sure whether something is reachable, only an attempt to connect can determine that. The reachability API can tell you if something is definitely not accessible (no route to host, etc.).

-josh
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Detecting network disconnected (From: "Justin C. Walker" <email@hidden>)

  • Prev by Date: Setting AirPort radio to base station mode
  • Next by Date: Re: Detecting network disconnected
  • Previous by thread: Setting AirPort radio to base station mode
  • Next by thread: Re: Detecting network disconnected
  • Index(es):
    • Date
    • Thread