Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find server is reachable with Reachability code in iPhone?


I have client server say "http://abc.com" and i want to check whether this server responding or not.
How to check this with Reachability code from apple?
As i see that code but not able to get where to write my client's url to check this.
Please suggest me.

like image 676
dks1725 Avatar asked Apr 28 '11 13:04

dks1725


People also ask

What is reachability in iOS?

When you use iPhone with one hand in Portrait orientation, you can use Reachability to lower the top half of the screen so it's within easy reach of your thumb. (Not supported on iPhone SE (1st generation).) Go to Settings > Accessibility > Touch, then turn on Reachability.

What is reachability alert?

Notification On Reachability. Through this service you will be notified if you try to call any number and was unreachable or switched off by receiving an SMS indicates that the number become available now.

What is reachability in iOS Swift?

swift. Reachability. swift is a replacement for Apple's Reachability sample, re-written in Swift with closures. It is compatible with iOS (8.0 - 12.0), OSX (10.9 - 10.14) and tvOS (9.0 - 12.0)


1 Answers

Here's a synchronous example. You'll probably want to do this asynchronously, but this will get you through for a quick check.

Reachability *netReach = [Reachability reachabilityWithHostName:@"host.name"];
//return [netReach currentReachabilityStatus];
NetworkStatus netStatus = [netReach currentReachabilityStatus];
if (netStatus==ReachableViaWiFi) {
    [ViewManager showStatus:@"Reachable (WiFi)!"];
} else if(netStatus==ReachableViaWWAN) {
    [ViewManager showStatus:@"Reachable (WWAN)!"];
} else {
    [ViewManager showStatus:@"Not reachable, aww :-("];
}

When using reachabilityWithHostName you have to remember that this is just the host name, there should be no http:// prefix or the like.

like image 192
Rudi Visser Avatar answered Oct 19 '22 11:10

Rudi Visser