• 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: Is the internet avaliable question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is the internet avaliable question


  • Subject: Re: Is the internet avaliable question
  • From: Kevin Bracey <email@hidden>
  • Date: Mon, 5 Apr 2004 13:44:39 +1200

Hmm, some saying they have no problems with SCNetwork, but I seem to be:

SCNetworkConnection docs have this rider

Note: Currently only PPP services can be controlled

does this mean that

SCNetworkCheckReachabilityByName

will only return

SCError() 4001
Network reachability cannot be determined ( which is what I get using it )

when on a LAN connected to the internet via a router or BaseStation?

Technote 1145 also contains
Finally, it's worth noting that the techniques discussed below only work if the modem is directly connected to the computer. If the computer's connectivity in indirectly run through a modem (for example, the computer is on a home AirPort network and the AirPort Base Station connects to the Internet via its modem), there is very little you can do to avoid nuisance calls.

The Problem:
I have users on LAN (both router and BaseStation) and PPP and some which switch back and forward, via location. They want to load a web page from my site. I want to "to avoid nuisance calls"

I would prefer not to ask , "Are you on the internet?" or let the browser time out if not. I would rather let the user know that this option is not available without going online, they can then connect to get it if they wish.

I'm now going in circles;-)

Maybe 2 steps?
First check SCNetworkCheckReachabilityByName for PPP and if that fails

Problems detecting an active internet connecting using SystemConfiguration
( also see http://cocoa.mamasam.com/COCOADEV/2003/03/1/58893.php )

- (BOOL)networkConnectionOK
{
BOOL result = NO;
SCNetworkConnectionFlags flags;

// IMPORTANT:
// To work with CodeWarrior you should set the
// "enums are always int" option, which the CWPro8
// Mach-O stationery fails to do.

assert(sizeof(SCNetworkConnectionFlags) == sizeof(int));

if ( SCNetworkCheckReachabilityByName("muratnkonar.com", &flags) )
{
result = !(flags & kSCNetworkFlagsConnectionRequired) && (flags
& kSCNetworkFlagsReachable);
}

return result;
}


then try and force it online with something like

-(IBAction)areWeLive:(id)sender
{
([NSString stringWithContentsOfURL:[NSURL
URLWithString:@"http://www.apple.com";]]) ? NSLog(@"We are online") : NSLog(@"We are offline");
}

if still no go then check with the user?

There is also an option mentioned to check the NetworkServices preferences.xml but that seems even tricker and I'm not sure what to look for or if it has the limitations outline above?

I'm sure a solution is just around the corner, probably just after I click send;-) Thanks for all your help and ideas. Such a common problem.

Cheers Kevin Bracey
_______________________________________________
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.


  • Follow-Ups:
    • Re: Is the internet avaliable question
      • From: m <email@hidden>
  • Prev by Date: Re: Search Field MenuItem Enabling
  • Next by Date: Re: -retain and -release Questions
  • Previous by thread: Re: Is the internet avaliable question
  • Next by thread: Re: Is the internet avaliable question
  • Index(es):
    • Date
    • Thread