• 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: to check wifi connection. how?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: to check wifi connection. how?


  • Subject: Re: to check wifi connection. how?
  • From: "Eric E. Dolecki" <email@hidden>
  • Date: Mon, 20 Apr 2009 10:45:57 -0400

- (BOOL) connectedToNetwork
{
    // Create zero addy
    struct sockaddr_in zeroAddress;
    bzero(&zeroAddress, sizeof(zeroAddress));
    zeroAddress.sin_len = sizeof(zeroAddress);
    zeroAddress.sin_family = AF_INET;

    // Recover reachability flags
    SCNetworkReachabilityRef defaultRouteReachability =
SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr
*)&zeroAddress);
    SCNetworkReachabilityFlags flags;

    BOOL didRetrieveFlags =
SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags);
    CFRelease(defaultRouteReachability);

    if (!didRetrieveFlags)
    {
        printf("Error. Could not recover network reachability flags\n");
        return 0;
    }

    BOOL isReachable = flags & kSCNetworkFlagsReachable;
    BOOL needsConnection = flags & kSCNetworkFlagsConnectionRequired;
    return (isReachable && !needsConnection) ? YES : NO;
}


On Mon, Apr 20, 2009 at 10:31 AM, Carlo Gulliani <email@hidden>wrote:

> is there easy way how to check is enabled wifi connection on mac or not? I
> need to show warning's alert (when app was launched) if the wifi's
> connection is not available.
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
>



--
http://ericd.net
Interactive design and development
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: to check wifi connection. how?
      • From: Carlo Gulliani <email@hidden>
References: 
 >to check wifi connection. how? (From: Carlo Gulliani <email@hidden>)

  • Prev by Date: to check wifi connection. how?
  • Next by Date: Re: to check wifi connection. how?
  • Previous by thread: to check wifi connection. how?
  • Next by thread: Re: to check wifi connection. how?
  • Index(es):
    • Date
    • Thread