ping to web server from iphone
Posted
by Sreelal
on Stack Overflow
See other posts from Stack Overflow
or by Sreelal
Published on 2010-03-25T04:06:44Z
Indexed on
2010/03/25
4:13 UTC
Read the original article
Hit count: 383
iphone-sdk
Hi , I am developing an aplication which needs to download some data from webserver.So i need to first ping to the web server to check whether the service is available after checking the internet connectivity .I used the following code to check server availability
` BOOL success = NO;
const char *host_name = [@"http://192.168.1.7:8080/TestWeb/webresources/"
cStringUsingEncoding:NSASCIIStringEncoding];
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL,
host_name);
SCNetworkReachabilityFlags flags;
success = SCNetworkReachabilityGetFlags(reachability, &flags);
BOOL isAvailable = success && (flags & kSCNetworkFlagsReachable) && !(flags & kSCNetworkFlagsConnectionRequired);
return isAvailable;
`
where my server is uploaded locally.But this code always return an invalid result,but it works correctly if i gave some exixting sites like google.com.Please let me know whats i am doing wrong..
© Stack Overflow or respective owner