• 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
How to get AirPort Connection Status
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to get AirPort Connection Status


  • Subject: How to get AirPort Connection Status
  • From: "Rashmi Vyshnavi" <email@hidden>
  • Date: Thu, 18 Sep 2008 10:50:23 +0600

I want to know when my computer connects/disconnects to WiFi/AirPort
network.
Is there a way to get the status of connection to a WiFi network. I tried
using System Configuration API,but I could not get the status. Here is the
snippet
 --
 static void MyNetworkConnectionCallBack(SCNetworkConnectionRef
connection,SCNetworkConnectionStatus stat,void *info)
{
printf("Call back called \n");
SCNetworkConnectionStatus status = SCNetworkConnectionGetStatus(connection);
switch(status) {
case kSCNetworkConnectionInvalid:
printf("Connection invalid\n");
break;
case kSCNetworkConnectionDisconnected:
printf("Connection disconnected\n");
break;
case kSCNetworkConnectionConnecting:
printf("Connection connecting\n");
break;
case kSCNetworkConnectionConnected:
printf("Connection connected\n");
break;
case kSCNetworkConnectionDisconnecting:
printf("Connection disconnecting\n");
break;
}

}

int main (int argc, const char * argv[]) {
CFDictionaryRef userOptions;
bool scResult;
SCNetworkConnectionContext scncctx = {0, NULL, NULL, NULL, NULL};

CFStringRef currentServiceId;

scResult = SCNetworkConnectionCopyUserPreferences(NULL, &currentServiceId,
&userOptions);


SCNetworkConnectionRef connection = nil;
connection = SCNetworkConnectionCreateWithServiceID (NULL,
currentServiceId,
MyNetworkConnectionCallBack, &scncctx );
 SCNetworkConnectionStatus status =
SCNetworkConnectionGetStatus(connection);
 if(status == kSCNetworkConnectionConnected)
printf("connected \n");
else
  printf("current status :%d\n", status);

SCNetworkConnectionScheduleWithRunLoop(connection,CFRunLoopGetCurrent(),kCFRunLoopDefaultMode);



CFRunLoopRun();

return 0;
}
--
Am able to get connection status if I connect to a modem, but it fails when
connected
to a WiFi/AirPort network.

Thanks,
Rashmi
_______________________________________________

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: How to get AirPort Connection Status
      • From: Bob Clark <email@hidden>
    • Re: How to get AirPort Connection Status
      • From: "Michael Ash" <email@hidden>
    • Re: How to get AirPort Connection Status
      • From: Jason Coco <email@hidden>
  • Prev by Date: Re: Utility/Floating window with titlebar on left side
  • Next by Date: Existence of Network
  • Previous by thread: Re: Listening for changes in a table
  • Next by thread: Re: How to get AirPort Connection Status
  • Index(es):
    • Date
    • Thread