4 #include <CoreFoundation/CoreFoundation.h>
5 #include <SystemConfiguration/SystemConfiguration.h>
6 #include <SystemConfiguration/SCPrivate.h>
8 #include "SCNetworkReachabilityInternal.h"
11 main(int argc
, char **argv
)
14 SCNetworkReachabilityRef target1
;
15 SCNetworkReachabilityRef target2
;
16 SCNetworkReachabilityRef target3
;
17 SCNetworkReachabilityRef target4
;
18 SCNetworkReachabilityRef target5
;
21 _sc_debug
= TRUE
; // extra reachability logging
23 target1
= SCNetworkReachabilityCreateWithName(NULL
, "web.apple.com");
24 ok
= __SCNetworkReachabilityServer_targetAdd(target1
);
26 SCLog(TRUE
, LOG_ERR
, CFSTR("No reachability server"));
30 target2
= SCNetworkReachabilityCreateWithName(NULL
, "www.comcast.net");
31 __SCNetworkReachabilityServer_targetAdd(target2
);
33 target3
= SCNetworkReachabilityCreateWithName(NULL
, "www.comcast.net");
34 __SCNetworkReachabilityServer_targetAdd(target3
);
36 target4
= SCNetworkReachabilityCreateWithName(NULL
, "www.nonexistenthost.com");
37 __SCNetworkReachabilityServer_targetAdd(target4
);
39 target5
= SCNetworkReachabilityCreateWithName(NULL
, "www.washingtonpost.com");
40 __SCNetworkReachabilityServer_targetAdd(target5
);
42 __SCNetworkReachabilityServer_targetStatus(target1
);
43 __SCNetworkReachabilityServer_targetStatus(target2
);
44 __SCNetworkReachabilityServer_targetStatus(target3
);
45 __SCNetworkReachabilityServer_targetStatus(target4
);
47 __SCNetworkReachabilityServer_targetMonitor(target1
, TRUE
);
48 __SCNetworkReachabilityServer_targetMonitor(target4
, TRUE
);
49 __SCNetworkReachabilityServer_targetMonitor(target5
, TRUE
);
51 __SCNetworkReachabilityServer_targetStatus(target4
);
52 __SCNetworkReachabilityServer_targetStatus(target3
);
53 __SCNetworkReachabilityServer_targetStatus(target2
);
54 __SCNetworkReachabilityServer_targetStatus(target1
);
58 __SCNetworkReachabilityServer_targetStatus(target1
);
59 __SCNetworkReachabilityServer_targetStatus(target4
);
60 __SCNetworkReachabilityServer_targetStatus(target1
);
61 __SCNetworkReachabilityServer_targetStatus(target4
);
63 __SCNetworkReachabilityServer_targetMonitor(target1
, FALSE
);
65 __SCNetworkReachabilityServer_targetStatus(target1
);
66 __SCNetworkReachabilityServer_targetStatus(target4
);
67 __SCNetworkReachabilityServer_targetStatus(target1
);
68 __SCNetworkReachabilityServer_targetStatus(target4
);
70 __SCNetworkReachabilityServer_targetMonitor(target4
, FALSE
);
72 __SCNetworkReachabilityServer_targetStatus(target1
);
73 __SCNetworkReachabilityServer_targetStatus(target4
);
75 // SCLog(TRUE, LOG_DEBUG, CFSTR("starting CFRunLoop"));
77 // SCLog(TRUE, LOG_DEBUG, CFSTR("CFRunLoop complete"));
79 SCLog(TRUE
, LOG_DEBUG
, CFSTR("sleeping"));
82 __SCNetworkReachabilityServer_targetStatus(target5
);
83 __SCNetworkReachabilityServer_targetRemove(target5
);
86 __SCNetworkReachabilityServer_targetRemove(target4
);
89 __SCNetworkReachabilityServer_targetRemove(target3
);
92 // __SCNetworkReachabilityServer_targetRemove(target2);
93 // CFRelease(target2);
95 // __SCNetworkReachabilityServer_targetRemove(target1);
96 // CFRelease(target1);