Reachability.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // Reachability.h
  3. // Inhealth
  4. //
  5. // Created by weclouds on 2020/7/29.
  6. // Copyright © 2020 weclouds. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <SystemConfiguration/SystemConfiguration.h>
  10. #import <netinet/in.h>
  11. typedef enum : NSInteger {
  12. NotReachable = 0,
  13. ReachableViaWiFi,
  14. ReachableViaWWAN
  15. } NetworkStatus;
  16. #pragma mark IPv6 Support
  17. //Reachability fully support IPv6. For full details, see ReadMe.md.
  18. extern NSString *kReachabilityChangedNotification;
  19. @interface Reachability : NSObject
  20. /*!
  21. * Use to check the reachability of a given host name.
  22. */
  23. + (instancetype)reachabilityWithHostName:(NSString *)hostName;
  24. /*!
  25. * Use to check the reachability of a given IP address.
  26. */
  27. + (instancetype)reachabilityWithAddress:(const struct sockaddr *)hostAddress;
  28. /*!
  29. * Checks whether the default route is available. Should be used by applications that do not connect to a particular host.
  30. */
  31. + (instancetype)reachabilityForInternetConnection;
  32. #pragma mark reachabilityForLocalWiFi
  33. //reachabilityForLocalWiFi has been removed from the sample. See ReadMe.md for more information.
  34. //+ (instancetype)reachabilityForLocalWiFi;
  35. /*!
  36. * Start listening for reachability notifications on the current run loop.
  37. */
  38. - (BOOL)startNotifier;
  39. - (void)stopNotifier;
  40. - (NetworkStatus)currentReachabilityStatus;
  41. /*!
  42. * WWAN may be available, but not active until a connection has been established. WiFi may require a connection for VPN on Demand.
  43. */
  44. - (BOOL)connectionRequired;
  45. @end