'How to detect connection status
I am using AsyncSocket in my iPhone telnet based app to communicate with sever. Communication is working fine.
If some one plug out the LAN cable from server. I want my app should show some alert.
Does anyone has any idea how I can achieve this?
Solution 1:[1]
Add an observer for the Network Reachability like this
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(myReachabilityDidChangedMethod)
name:kReachabilityChangedNotification
object:nil];
Reachability *reachability;
reachability = [Reachability reachabilityForInternetConnection];
[reachability startNotifier];
So when ever Network state changes you will be notified using Observer Method -
(void)myReachabilityDidChangedMethod:(Reachability*){
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sumanth |
