HDReachability.h 1.57 KB
Newer Older
Han Ruisong's avatar
Han Ruisong committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
 Copyright (C) 2016 Apple Inc. All Rights Reserved.
 See LICENSE.txt for this sample’s licensing information
 
 Abstract:
 Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
 */

#import <Foundation/Foundation.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <netinet/in.h>


typedef enum : NSInteger {
Han Ruisong's avatar
Han Ruisong committed
15
16
17
18
	HDNotReachable = 0,
	HDReachableViaWiFi,
	HDReachableViaWWAN
} HDNetworkStatus;
Han Ruisong's avatar
Han Ruisong committed
19
20
21
22
23

#pragma mark IPv6 Support
//Reachability fully support IPv6.  For full details, see ReadMe.md.


Han Ruisong's avatar
Han Ruisong committed
24
extern NSString *kHDReachabilityChangedNotification;
Han Ruisong's avatar
Han Ruisong committed
25
26


Han Ruisong's avatar
Han Ruisong committed
27
@interface HDReachability : NSObject
Han Ruisong's avatar
Han Ruisong committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

/*!
 * Use to check the reachability of a given host name.
 */
+ (instancetype)reachabilityWithHostName:(NSString *)hostName;

/*!
 * Use to check the reachability of a given IP address.
 */
+ (instancetype)reachabilityWithAddress:(const struct sockaddr *)hostAddress;

/*!
 * Checks whether the default route is available. Should be used by applications that do not connect to a particular host.
 */
+ (instancetype)reachabilityForInternetConnection;


#pragma mark reachabilityForLocalWiFi
//reachabilityForLocalWiFi has been removed from the sample.  See ReadMe.md for more information.
//+ (instancetype)reachabilityForLocalWiFi;

/*!
 * Start listening for reachability notifications on the current run loop.
 */
- (BOOL)startNotifier;
- (void)stopNotifier;

Han Ruisong's avatar
Han Ruisong committed
55
- (HDNetworkStatus)currentReachabilityStatus;
Han Ruisong's avatar
Han Ruisong committed
56
57
58
59
60
61
62
63
64

/*!
 * WWAN may be available, but not active until a connection has been established. WiFi may require a connection for VPN on Demand.
 */
- (BOOL)connectionRequired;

@end