I want to check the internet connection in my iPhone app.
The app needs to know, if the phone is connected via wifi and if wifi is connected with the strict router.
For example: It is a app to order drinks in a bar. The user is only allowed to order something if he is connected to the network of the bar.
I tried:
- (IBAction)buttonCHECKNETWORK:(id)sender{
struct sockaddr_in callAddress;
callAddress.sin_len = sizeof(callAddress);
callAddress.sin_family = AF_INET;
callAddress.sin_port = htons(24);
callAddress.sin_addr.s_addr = inet_addr("152.465.456.975");
Reachability *hostReach = [Reachability reachabilityWithAddress:&callAddress];
NetworkStatus netStatus = [hostReach currentReachabilityStatus];
if (netStatus == NotReachable)
{
NSLog(@"IP NotReachable");
}
if (netStatus == ReachableViaWiFi)
{
NSLog(@"IP ReachableViaWiFi");
}
if (netStatus == ReachableViaWWAN)
{
NSLog(@"IP ReachableViaWWAN");
} }
But every IP is reachable (also this fictional IP in my code)... I would like to put the Router IP in 'callAddress'. Or the name of the router or something like that.. It would not be reachable if the user is connected via 3G.