Problems detecting an active internet connecting using SystemConfiguration
Problems detecting an active internet connecting using SystemConfiguration
- Subject: Problems detecting an active internet connecting using SystemConfiguration
- From: Marc Weil <email@hidden>
- Date: Sat, 15 Mar 2003 08:40:02 -0500
Hello everyone,
I have been trying to use SCNetwork.h's SCNetworkCheckReachabilityByName()
function for detecting an active internet connection, but it doesn't seem to
work right. It only worked correctly once (unless I am misreading what its
constants mean). I am on a LAN connected to a cable modem, so I am always
on. I tried using the method with my Ethernet plugged in, and it set the
flags I passed to it to kSCNetworkFlagsReachable (which is to be expected).
It didn't set any other values (which is also to be expected). For your
reference, here is the enumeration of constants in SCNetwork.h (you'll have
to open the header file on your end to see all of the comments explaining
what the constants are for).
kSCNetworkFlagsTransientConnection = 1<<0,
kSCNetworkFlagsReachable = 1<<1,
kSCNetworkFlagsConnectionRequired = 1<<2,
kSCNetworkFlagsConnectionAutomatic = 1<<3,
kSCNetworkFlagsInterventionRequired = 1<<4,
I also tried unpluging my Ethernet cable (without changing any network
settings), and flags becomes 0. I'm not sure why, this might also be okay.
Now, here's where the problems come in. I make some dialup settings in
Network Preferences and set my computer to connect via the internal modem
and PPP. I am sure to UNCHECK the box in the PPP settings that says "Connect
automatically when needed". I even unplug my Ethernet cable again for good
measure. This time, the flags are set to 7. So here are the values for all
of the constants with this number (using bitwise and (&) to mask the flags):
kSCNetworkFlagsTransientConnection = 1
kSCNetworkFlagsReachable = 2
kSCNetworkFlagsConnectionRequired = 4
kSCNetworkFlagsConnectionAutomatic = 0
kSCNetworkFlagsInterventionRequired= 0
How the heck is the network address I passed reachable when there is no
internet connection?! I thought there were some packets sent out to the
address, and if they returned, there is an active connection. There is
obviously no way that I am on the internet, so kSCNetworkFlagsReachable
should be 0. kSCNetworkFlagsConnectionAutomatic is 0 (which is correct
because I set it so there was no entered dialup password, and so it wouldn't
dialup automatically). But if that is 0, then
kSCNetworkFlagsInterventionRequired shouldn't be 0 because there DOES need
to be user intervention in order to connect to the internet.
This is really baffling me! Is this a bug, or am I just doing something
wrong? Here are my two statements for calling the function and detecting
what flags was set to:
SCNetworkConnectionFlags flags;
Boolean reachable =
SCNetworkCheckReachabilityByName("www.northsoftproductions.com", &flags);
if(reachable && !(flags & kSCNetworkFlagsInterventionRequired)) {
So, does anybody have any ideas?
Sincerely,
Marc Weil
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.