Possible Duplicate:
Ping with iPhone SDK
I am creating a application. Where before sending request to server i need to long server. How can i do that?
Possible Duplicate:
Ping with iPhone SDK
I am creating a application. Where before sending request to server i need to long server. How can i do that?
You should check the reachability utility that Apple made:
Reachability on developer.apple.com
I think that will do what you want to do.
EDIT
use it like this:
+(BOOL)canConnect {
Reachability *r = [Reachability reachabilityWithHostName:@"www.example.com"];
NetworkStatus internetStatus = [r currentReachabilityStatus];
return ((internetStatus == ReachableViaWiFi) || (internetStatus == ReachableViaWWAN));
}
It will check if you can connect to the internet, and if you can connect to the server with the given adress/ip.
Check the Reachability example in apple. That provides step by step to check if ip is connectable.
You may use a lot of variants starting from NSURLRequest
and so on