+2  A: 

You should probably be using +[Reachability reachabilityForInternetConnection] rather than reachability for a particular name (unless of course that's what you actually need).

There could be all manner of reasons that a particular server might not be reachable while you still have a working internet connection, after all.

This is what I do:

BOOL hasInet;
Reachability *connectionMonitor = [Reachability reachabilityForInternetConnection];
[[NSNotificationCenter defaultCenter]
    addObserver: self
    selector: @selector(inetAvailabilityChanged:)
    name:  kReachabilityChangedNotification
    object: connectionMonitor];

hasInet = [connectionMonitor currentReachabilityStatus] != NotReachable;

and then

-(void)inetAvailabilityChanged:(NSNotification *)notice {
    Reachability *r = (Reachability *)[notice object];
    hasInet = [r currentReachabilityStatus] != NotReachable;
}

which works nicely for me.

Frank Shearar
thanks but I also find another way to solve my problem. By reading the Reachability_readme.txt, they said that the connection can take time by trying to identify the hostName (and so fail sometimes), so I simply use the google DNS like (74.125.71.104) and now its working fine and its fast too.
ludo
Hi ludo and Frank, I used your code and the Reachability sample code, but it still cannot detect the Internet's availability correctly. How do you use the ip address 74.125.71.104? I guess should not be reachabilityWithAddress: (const struct sockaddr_in*) hostAddress; or reachabilityWithHostName: (NSString*) hostName? Thanks.
lionfly