Checking for internet connection?

  • Is there any way to check to see if there is an active internet
    connection?

    - Paul
  • I'm not sure about a Cocoa API, but Core Foundation's System Configuration
    Framework's "Reachability" API can tell you:

    http://developer.apple.com/documentation/Networking/Conceptual/SystemConfig
    F

    rameworks/SC_ReachConnect/chapter_5_section_4.html

    Greg

    On 2/17/06 9:24 AM, "Paul J. Lucas" <pauljlucas...> wrote:

    > Is there any way to check to see if there is an active internet
    > connection?
    >
    > - Paul
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/<greghe...>
    >
    > This email sent to <greghe...>
  • From a while back on this list:

    On 2/17/06 9:24 AM, "Paul J. Lucas" <pauljlucas...> wrote:
    > Is there any way to check to see if there is an active internet
    > connection?
    >
    > - Paul

    On Friday, February 17, 2006, at 05:41  pm, Greg Herlihy wrote:
    > I'm not sure about a Cocoa API, but Core Foundation's System
    > Configuration
    > Framework's "Reachability" API can tell you:
    >
    > http://developer.apple.com/documentation/Networking/Conceptual/
    > SystemConfigF
    > rameworks/SC_ReachConnect/chapter_5_section_4.html
    >
    > Greg

    The two functions on that page, SCNetworkCheckReachabilityByAddress and
    SCNetworkCheckReachabilityByName (regarding pre 10.3), checks the
    availability of another external host. That's really the best way to
    see if the computer has a connection? Check to see if say Amazon are
    contactable and from that assume that the machine you're on has a
    connection? That's really crap I reckon. Surely there's a reasonable
    way to find out if the machine is currently connected to the net or not
    (OS X 10.2+)?

    Thanks, Ben.
  • On Saturday, October 14, 2006, at 12:56  pm, Ben Dougall wrote:

    > From a while back on this list:
    >
    > On 2/17/06 9:24 AM, "Paul J. Lucas" <pauljlucas...> wrote:
    >> Is there any way to check to see if there is an active internet
    >> connection?
    >>
    >> - Paul
    >
    > On Friday, February 17, 2006, at 05:41  pm, Greg Herlihy wrote:
    >> I'm not sure about a Cocoa API, but Core Foundation's System
    >> Configuration
    >> Framework's "Reachability" API can tell you:
    >>
    >> http://developer.apple.com/documentation/Networking/Conceptual/
    >> SystemConfigF
    >> rameworks/SC_ReachConnect/chapter_5_section_4.html
    >>
    >> Greg
    >
    >
    > The two functions on that page, SCNetworkCheckReachabilityByAddress
    > and SCNetworkCheckReachabilityByName (regarding pre 10.3), checks the
    > availability of another external host. That's really the best way to
    > see if the computer has a connection? Check to see if say Amazon are
    > contactable and from that assume that the machine you're on has a
    > connection? That's really crap I reckon. Surely there's a reasonable
    > way to find out if the machine is currently connected to the net or
    > not (OS X 10.2+)?

    In fact what I'd really like to know, is how to get the information you
    can get via the Internet Connect app using AppleScript, e.g.:

    {user name:"", server name:"", speed:115200, seconds connected:6028,
    seconds remaining:-1, bytes received:28671527, bytes sent:13430858,
    protocol:0, message:"", state:4}

    Is there any way to get that information, particularly whether there's
    a connection or not, speed, and seconds connected,
    directly/programmatically without AppleScript and the need for Internet
    Connect to open?

    Thanks, Ben.
  • On 14 okt 2006, at 13.56, Ben Dougall wrote:

    > The two functions on that page, SCNetworkCheckReachabilityByAddress
    > and SCNetworkCheckReachabilityByName (regarding pre 10.3), checks
    > the availability of another external host. That's really the best
    > way to see if the computer has a connection? Check to see if say
    > Amazon are contactable and from that assume that the machine you're
    > on has a connection? That's really crap I reckon. Surely there's a
    > reasonable way to find out if the machine is currently connected to
    > the net or not (OS X 10.2+)?

    How do you think it could work otherwise? What does "connected to the
    internet" mean to you?

    Sure, your computer can detect that it is connected to an IP network
    without having to ping some host on the Internet, but that's probably
    not what you're looking for.

    j o a r
  • On Saturday, October 14, 2006, at 07:44  pm, j o a r wrote:

    >
    > On 14 okt 2006, at 13.56, Ben Dougall wrote:
    >
    >> The two functions on that page, SCNetworkCheckReachabilityByAddress
    >> and SCNetworkCheckReachabilityByName (regarding pre 10.3), checks the
    >> availability of another external host. That's really the best way to
    >> see if the computer has a connection? Check to see if say Amazon are
    >> contactable and from that assume that the machine you're on has a
    >> connection? That's really crap I reckon. Surely there's a reasonable
    >> way to find out if the machine is currently connected to the net or
    >> not (OS X 10.2+)?
    >
    > How do you think it could work otherwise? What does "connected to the
    > internet" mean to you?
    >
    > Sure, your computer can detect that it is connected to an IP network
    > without having to ping some host on the Internet, but that's probably
    > not what you're looking for.

    Yes it is -- that's what I'm after (if "IP network" means the
    internet). I want the same info as the Internet Connect app has -- it
    displays "connected" or "disconnected". I'm also after the same info
    that the Internet Connect app makes available via AppleScript
    (specifically time connected and speed) without having to use
    AppleScript and open the Internet Connect app if possible?

    Thanks, Ben.
  • On 14 okt 2006, at 20.55, Ben Dougall wrote:

    > Yes it is -- that's what I'm after (if "IP network" means the
    > internet).

    It doesn't , and that's the point. As an example, if you have an
    AirPort as a home router, it will give you a local IP address
    regardless of if the AirPort itself is connected to the Internet or
    not. So, in that case you will have a connection to an IP network,
    but that network will not be connected to the Internet.

    j o a r
  • On Saturday, October 14, 2006, at 08:07  pm, j o a r wrote:

    >
    > On 14 okt 2006, at 20.55, Ben Dougall wrote:
    >
    >> Yes it is -- that's what I'm after (if "IP network" means the
    >> internet).
    >
    > It doesn't , and that's the point. As an example, if you have an
    > AirPort as a home router, it will give you a local IP address
    > regardless of if the AirPort itself is connected to the Internet or
    > not. So, in that case you will have a connection to an IP network, but
    > that network will not be connected to the Internet.

    I see, OK thanks.

    I'm trying to find out how to get the information that the Internet
    Connect app has access to and displays, specifically
    "connected"/"disconnected" plus the speed and time in seconds
    connected. This information can be got via AppleScript thus requiring
    the Internet Connect app to open but I'm wondering if that information
    can be acquired programmatically from within a Cocoa app without AS
    somehow? Possible? If so how? Any pointers to how to do that would be
    much appreciated. If not I'll just use AS as I'm doing at the moment
    but it's very annoying having the I.C. app open and quit periodically
    -- be much better if I didn't have to use AS.

    Thanks, Ben.
  • On 14 okt 2006, at 21.37, Ben Dougall wrote:

    > I'm trying to find out how to get the information that the Internet
    > Connect app has access to and displays, specifically
    > "connected"/"disconnected" plus the speed and time in seconds
    > connected.

    But that status is for "transient" connections (like a modem
    connection), right? I think (by looking at the API, I haven't tried
    it) that you can use the System Configuration APIs for some of that,
    at least the connected / disconnected state, and the duration. Not
    sure about bitrate, bits transfered, and stuff like that.

    j o a r
  • you could parse the output of the 'ifconfig' (no command line
    arguments) command, or look at the source for ifconfig and determine
    how it works.  ifconfig is a big complicated program though so thats
    not an ideal solution, but it might be a start.  Also, Im not sure if/
    how it deals with PPP connections.

    spencer

    On Oct 14, 2006, at 3:37 PM, Ben Dougall wrote:

    >
    > On Saturday, October 14, 2006, at 08:07  pm, j o a r wrote:
    >
    >>
    >> On 14 okt 2006, at 20.55, Ben Dougall wrote:
    >>
    >>> Yes it is -- that's what I'm after (if "IP network" means the
    >>> internet).
    >>
    >> It doesn't , and that's the point. As an example, if you have an
    >> AirPort as a home router, it will give you a local IP address
    >> regardless of if the AirPort itself is connected to the Internet
    >> or not. So, in that case you will have a connection to an IP
    >> network, but that network will not be connected to the Internet.
    >
    > I see, OK thanks.
    >
    > I'm trying to find out how to get the information that the Internet
    > Connect app has access to and displays, specifically
    > "connected"/"disconnected" plus the speed and time in seconds
    > connected. This information can be got via AppleScript thus
    > requiring the Internet Connect app to open but I'm wondering if
    > that information can be acquired programmatically from within a
    > Cocoa app without AS somehow? Possible? If so how? Any pointers to
    > how to do that would be much appreciated. If not I'll just use AS
    > as I'm doing at the moment but it's very annoying having the I.C.
    > app open and quit periodically -- be much better if I didn't have
    > to use AS.
    >
    > Thanks, Ben.
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/spencer.salazar%
    > 40gmail.com
    >
    > This email sent to <spencer.salazar...>
  • On Saturday, October 14, 2006, at 08:50  pm, j o a r wrote:

    >
    > On 14 okt 2006, at 21.37, Ben Dougall wrote:
    >
    >> I'm trying to find out how to get the information that the Internet
    >> Connect app has access to and displays, specifically
    >> "connected"/"disconnected" plus the speed and time in seconds
    >> connected.
    >
    > But that status is for "transient" connections (like a modem
    > connection), right? I think (by looking at the API, I haven't tried
    > it) that you can use the System Configuration APIs for some of that,
    > at least the connected / disconnected state,

    I can't see one that does that. The closest two functions that I know
    of, SCNetworkCheckReachabilityByAddress and
    SCNetworkCheckReachabilityByName, require a particular host to try
    rather than just saying yes connected, or no not connected.

    > and the duration. Not sure about bitrate, bits transfered, and stuff
    > like that.
  • On Oct 14, 2006, at 1:11 PM, Ben Dougall wrote:

    >
    > On Saturday, October 14, 2006, at 08:50  pm, j o a r wrote:
    >
    >>
    >> On 14 okt 2006, at 21.37, Ben Dougall wrote:
    >>
    >>> I'm trying to find out how to get the information that the
    >>> Internet Connect app has access to and displays, specifically
    >>> "connected"/"disconnected" plus the speed and time in seconds
    >>> connected.
    >>
    >> But that status is for "transient" connections (like a modem
    >> connection), right? I think (by looking at the API, I haven't
    >> tried it) that you can use the System Configuration APIs for some
    >> of that, at least the connected / disconnected state,
    >
    > I can't see one that does that. The closest two functions that I
    > know of, SCNetworkCheckReachabilityByAddress and
    > SCNetworkCheckReachabilityByName, require a particular host to try
    > rather than just saying yes connected, or no not connected.

    <http://developer.apple.com/documentation/Networking/Conceptual/
    SystemConfigFrameworks/SC_ReachConnect/chapter_5_section_5.html
    >

    -Shawn
  • On Saturday, October 14, 2006, at 10:00  pm, Shawn Erickson wrote:

    >
    > On Oct 14, 2006, at 1:11 PM, Ben Dougall wrote:
    >
    >>
    >> On Saturday, October 14, 2006, at 08:50  pm, j o a r wrote:
    >>
    >>>
    >>> On 14 okt 2006, at 21.37, Ben Dougall wrote:
    >>>
    >>>> I'm trying to find out how to get the information that the Internet
    >>>> Connect app has access to and displays, specifically
    >>>> "connected"/"disconnected" plus the speed and time in seconds
    >>>> connected.
    >>>
    >>> But that status is for "transient" connections (like a modem
    >>> connection), right? I think (by looking at the API, I haven't tried
    >>> it) that you can use the System Configuration APIs for some of that,
    >>> at least the connected / disconnected state,
    >>
    >> I can't see one that does that. The closest two functions that I know
    >> of, SCNetworkCheckReachabilityByAddress and
    >> SCNetworkCheckReachabilityByName, require a particular host to try
    >> rather than just saying yes connected, or no not connected.
    >
    > <http://developer.apple.com/documentation/Networking/Conceptual/
    > SystemConfigFrameworks/SC_ReachConnect/chapter_5_section_5.html>
    >
    > -Shawn

    Thanks but that's the page I talked about to start with:

    On Saturday, October 14, 2006, at 12:56  pm, Ben Dougall wrote:

    > From a while back on this list:
    >
    > On 2/17/06 9:24 AM, "Paul J. Lucas" <pauljlucas...> wrote:
    >> Is there any way to check to see if there is an active internet
    >> connection?
    >>
    >> - Paul
    >
    > On Friday, February 17, 2006, at 05:41  pm, Greg Herlihy wrote:
    >> I'm not sure about a Cocoa API, but Core Foundation's System
    >> Configuration
    >> Framework's "Reachability" API can tell you:
    >>
    >> http://developer.apple.com/documentation/Networking/Conceptual/
    >> SystemConfigF
    >> rameworks/SC_ReachConnect/chapter_5_section_4.html
    >>
    >> Greg
    >
    >
    > The two functions on that page, SCNetworkCheckReachabilityByAddress
    > and SCNetworkCheckReachabilityByName (regarding pre 10.3), checks the
    > availability of another external host. That's really the best way to
    > see if the computer has a connection? Check to see if say Amazon are
    > contactable and from that assume that the machine you're on has a
    > connection? That's really crap I reckon. Surely there's a reasonable
    > way to find out if the machine is currently connected to the net or
    > not (OS X 10.2+)?
  • On Saturday, October 14, 2006, at 10:06  pm, Ben Dougall wrote:
    > On Saturday, October 14, 2006, at 10:00  pm, Shawn Erickson wrote:
    >>
    >> <http://developer.apple.com/documentation/Networking/Conceptual/
    >> SystemConfigFrameworks/SC_ReachConnect/chapter_5_section_5.html>
    >>
    >> -Shawn
    >
    > Thanks but that's the page I talked about to start with:

    Oh no it's not -- sorry. Yes that look useful. Thanks.
  • On Oct 14, 2006, at 1:11 PM, Ben Dougall wrote:

    > I can't see one that does that. The closest two functions that I
    > know of, SCNetworkCheckReachabilityByAddress and
    > SCNetworkCheckReachabilityByName, require a particular host to try
    > rather than just saying yes connected, or no not connected.

    This might be of some help, at least as a starting point:

    Checking Network Status with CFNetDiagnostics
    http://theocacao.com/document.page/206

    CFNetDiagnostics can also provide a nice dialog for the user if
    they're not connected.

        - Scott
  • On Saturday, October 14, 2006, at 10:10  pm, Ben Dougall wrote:

    >
    > On Saturday, October 14, 2006, at 10:06  pm, Ben Dougall wrote:
    >> On Saturday, October 14, 2006, at 10:00  pm, Shawn Erickson wrote:
    >>>
    >>> <http://developer.apple.com/documentation/Networking/Conceptual/
    >>> SystemConfigFrameworks/SC_ReachConnect/chapter_5_section_5.html>
    >>>
    >>> -Shawn
    >>
    >> Thanks but that's the page I talked about to start with:
    >
    > Oh no it's not -- sorry. Yes that look useful. Thanks.

    Unfortunately it's all for 10.3 and above. I need it to work on 10.2.
    Oh well, AppleScript + Internet Connect app it'll have to be, or ping
    Amazon.com repeatedly to see if it's connected.

    Thanks, Ben.
  • Ben Dougall wrote:
    > Unfortunately it's all for 10.3 and above. I need it to work on 10.2.
    > Oh well, AppleScript + Internet Connect app it'll have to be, or ping
    > Amazon.com repeatedly to see if it's connected.
    Couldn't you query something against one/some of the root DNS servers?
    Those pretty much must be up, and it also shows that you are connected
    to the big-I Internet and not just some IP network. You may be able to
    ping them, but I would guess that's not guaranteed, whereas a DNS query
    is their real job. Same with Amazon - they don't have to answer your
    pings, but they do have to answer your HTTP request - try a HTTP HEAD or
    something small like that instead.
previous month february 2006 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28          
Go to today