<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: iPhone Network Connectivity Test Example</title>
	<atom:link href="http://www.chrisdanielson.com/2009/07/22/iphone-network-connectivity-test-example/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chrisdanielson.com/2009/07/22/iphone-network-connectivity-test-example/</link>
	<description>Trials and Tribulations of a Software Developer</description>
	<lastBuildDate>Mon, 30 Jan 2012 21:45:46 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Chris Danielson</title>
		<link>http://www.chrisdanielson.com/2009/07/22/iphone-network-connectivity-test-example/comment-page-1/#comment-598</link>
		<dc:creator>Chris Danielson</dc:creator>
		<pubDate>Wed, 07 Dec 2011 15:01:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisdanielson.com/?p=70#comment-598</guid>
		<description>The fix for what you are asking is to actually try and pull say http://google.com in your initial request.  I hate pinging Apple or Google in my tests, but it is in fact a more complete implementation.  You can find a great method that does this in the AppiRater source code located at:
&lt;a href=&quot;https://github.com/arashpayan/appirater&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arashpayan/appirater&lt;/a&gt;
&lt;code&gt;- (BOOL)connectedToNetwork {
    // Create zero addy
    struct sockaddr_in zeroAddress;
    bzero(&amp;zeroAddress, sizeof(zeroAddress));
    zeroAddress.sin_len = sizeof(zeroAddress);
    zeroAddress.sin_family = AF_INET;

    // Recover reachability flags
    SCNetworkReachabilityRef defaultRouteReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&amp;zeroAddress);
    SCNetworkReachabilityFlags flags;

    BOOL didRetrieveFlags = SCNetworkReachabilityGetFlags(defaultRouteReachability, &amp;flags);
    CFRelease(defaultRouteReachability);

    if (!didRetrieveFlags)
    {
        NSLog(@&quot;Error. Could not recover network reachability flags&quot;);
        return NO;
    }

    BOOL isReachable = flags &amp; kSCNetworkFlagsReachable;
    BOOL needsConnection = flags &amp; kSCNetworkFlagsConnectionRequired;
	BOOL nonWiFi = flags &amp; kSCNetworkReachabilityFlagsTransientConnection;

	NSURL *testURL = [NSURL URLWithString:@&quot;http://www.apple.com/&quot;];
	NSURLRequest *testRequest = [NSURLRequest requestWithURL:testURL  cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:20.0];
	NSURLConnection *testConnection = [[NSURLConnection alloc] initWithRequest:testRequest delegate:self];

    return ((isReachable &amp;&amp; !needsConnection) &#124;&#124; nonWiFi) ? (testConnection ? YES : NO) : NO;
}&lt;/code&gt;

Kind Regards,
Chris</description>
		<content:encoded><![CDATA[<p>The fix for what you are asking is to actually try and pull say <a href="http://google.com" rel="nofollow">http://google.com</a> in your initial request.  I hate pinging Apple or Google in my tests, but it is in fact a more complete implementation.  You can find a great method that does this in the AppiRater source code located at:<br />
<a href="https://github.com/arashpayan/appirater" rel="nofollow">https://github.com/arashpayan/appirater</a><br />
<code>- (BOOL)connectedToNetwork {<br />
    // Create zero addy<br />
    struct sockaddr_in zeroAddress;<br />
    bzero(&amp;zeroAddress, sizeof(zeroAddress));<br />
    zeroAddress.sin_len = sizeof(zeroAddress);<br />
    zeroAddress.sin_family = AF_INET;</p>
<p>    // Recover reachability flags<br />
    SCNetworkReachabilityRef defaultRouteReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&amp;zeroAddress);<br />
    SCNetworkReachabilityFlags flags;</p>
<p>    BOOL didRetrieveFlags = SCNetworkReachabilityGetFlags(defaultRouteReachability, &amp;flags);<br />
    CFRelease(defaultRouteReachability);</p>
<p>    if (!didRetrieveFlags)<br />
    {<br />
        NSLog(@"Error. Could not recover network reachability flags");<br />
        return NO;<br />
    }</p>
<p>    BOOL isReachable = flags &amp; kSCNetworkFlagsReachable;<br />
    BOOL needsConnection = flags &amp; kSCNetworkFlagsConnectionRequired;<br />
	BOOL nonWiFi = flags &amp; kSCNetworkReachabilityFlagsTransientConnection;</p>
<p>	NSURL *testURL = [NSURL URLWithString:@"http://www.apple.com/"];<br />
	NSURLRequest *testRequest = [NSURLRequest requestWithURL:testURL  cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:20.0];<br />
	NSURLConnection *testConnection = [[NSURLConnection alloc] initWithRequest:testRequest delegate:self];</p>
<p>    return ((isReachable &amp;&amp; !needsConnection) || nonWiFi) ? (testConnection ? YES : NO) : NO;<br />
}</code></p>
<p>Kind Regards,<br />
Chris</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hamon Raphaël</title>
		<link>http://www.chrisdanielson.com/2009/07/22/iphone-network-connectivity-test-example/comment-page-1/#comment-594</link>
		<dc:creator>Hamon Raphaël</dc:creator>
		<pubDate>Mon, 05 Dec 2011 15:40:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisdanielson.com/?p=70#comment-594</guid>
		<description>Hi !

It seems great, but I&#039;ve found an issue. With some wifi hotspots, the iphone is connected to the hotspot but not logged into the hotspot system but the iphone stays &quot;connected&quot; to the hotspot but doesn&#039;t have internet access. And so, this test doesn&#039;t work for that kind of situation.

Raphaël</description>
		<content:encoded><![CDATA[<p>Hi !</p>
<p>It seems great, but I&#8217;ve found an issue. With some wifi hotspots, the iphone is connected to the hotspot but not logged into the hotspot system but the iphone stays &#8220;connected&#8221; to the hotspot but doesn&#8217;t have internet access. And so, this test doesn&#8217;t work for that kind of situation.</p>
<p>Raphaël</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Danielson</title>
		<link>http://www.chrisdanielson.com/2009/07/22/iphone-network-connectivity-test-example/comment-page-1/#comment-514</link>
		<dc:creator>Chris Danielson</dc:creator>
		<pubDate>Tue, 17 May 2011 03:01:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisdanielson.com/?p=70#comment-514</guid>
		<description>Brian,
Ideally, you would avoid redundantly putting this code in every page and access either a static method or an instance method on a particular object.</description>
		<content:encoded><![CDATA[<p>Brian,<br />
Ideally, you would avoid redundantly putting this code in every page and access either a static method or an instance method on a particular object.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://www.chrisdanielson.com/2009/07/22/iphone-network-connectivity-test-example/comment-page-1/#comment-511</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Mon, 16 May 2011 22:56:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisdanielson.com/?p=70#comment-511</guid>
		<description>Should you put this on all pages that make a URL call?</description>
		<content:encoded><![CDATA[<p>Should you put this on all pages that make a URL call?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Hoyer</title>
		<link>http://www.chrisdanielson.com/2009/07/22/iphone-network-connectivity-test-example/comment-page-1/#comment-490</link>
		<dc:creator>Andrew Hoyer</dc:creator>
		<pubDate>Fri, 25 Feb 2011 19:44:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisdanielson.com/?p=70#comment-490</guid>
		<description>Waleed, you need to include these at the top:

#import 
#import </description>
		<content:encoded><![CDATA[<p>Waleed, you need to include these at the top:</p>
<p>#import<br />
#import</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: waleed</title>
		<link>http://www.chrisdanielson.com/2009/07/22/iphone-network-connectivity-test-example/comment-page-1/#comment-456</link>
		<dc:creator>waleed</dc:creator>
		<pubDate>Wed, 22 Sep 2010 03:10:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisdanielson.com/?p=70#comment-456</guid>
		<description>his great but its not woking for me

am getting

  &quot;_SCNetworkReachabilityGetFlags&quot;, referenced from:
      -[TestViewController connectedToNetwork] in TestViewController.o
  &quot;_SCNetworkReachabilityCreateWithAddress&quot;, referenced from:
      -[TestViewController connectedToNetwork] in TestViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status</description>
		<content:encoded><![CDATA[<p>his great but its not woking for me</p>
<p>am getting</p>
<p>  &#8220;_SCNetworkReachabilityGetFlags&#8221;, referenced from:<br />
      -[TestViewController connectedToNetwork] in TestViewController.o<br />
  &#8220;_SCNetworkReachabilityCreateWithAddress&#8221;, referenced from:<br />
      -[TestViewController connectedToNetwork] in TestViewController.o<br />
ld: symbol(s) not found<br />
collect2: ld returned 1 exit status</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Danielson</title>
		<link>http://www.chrisdanielson.com/2009/07/22/iphone-network-connectivity-test-example/comment-page-1/#comment-419</link>
		<dc:creator>Chris Danielson</dc:creator>
		<pubDate>Wed, 26 May 2010 14:44:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisdanielson.com/?p=70#comment-419</guid>
		<description>Patrick,
I don&#039;t think the SCNetworkReachability will handle enumerating through the known access points.  I did a quick check &lt;a href=&quot;http://developer.apple.com/iphone/library/documentation/SystemConfiguration/Reference/SCNetworkReachabilityRef/Reference/reference.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, and didn&#039;t see anything.
Wish I could help you more on this endeavor.  Good luck!
-Chris</description>
		<content:encoded><![CDATA[<p>Patrick,<br />
I don&#8217;t think the SCNetworkReachability will handle enumerating through the known access points.  I did a quick check <a href="http://developer.apple.com/iphone/library/documentation/SystemConfiguration/Reference/SCNetworkReachabilityRef/Reference/reference.html" rel="nofollow">here</a>, and didn&#8217;t see anything.<br />
Wish I could help you more on this endeavor.  Good luck!<br />
-Chris</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: patrick m lim</title>
		<link>http://www.chrisdanielson.com/2009/07/22/iphone-network-connectivity-test-example/comment-page-1/#comment-415</link>
		<dc:creator>patrick m lim</dc:creator>
		<pubDate>Tue, 18 May 2010 01:42:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisdanielson.com/?p=70#comment-415</guid>
		<description>Hi Chris,

I&#039;m pretty new to iPhone app development especially Cocoa and Obj C. I have an application where I need to detect wifi access points (minimum of 2 APs). Does the SCNetworkReachability framework allow me to do that? 

Thanks for clearing my doubts!

Warmest Regards
Patrick</description>
		<content:encoded><![CDATA[<p>Hi Chris,</p>
<p>I&#8217;m pretty new to iPhone app development especially Cocoa and Obj C. I have an application where I need to detect wifi access points (minimum of 2 APs). Does the SCNetworkReachability framework allow me to do that? </p>
<p>Thanks for clearing my doubts!</p>
<p>Warmest Regards<br />
Patrick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Danielson</title>
		<link>http://www.chrisdanielson.com/2009/07/22/iphone-network-connectivity-test-example/comment-page-1/#comment-412</link>
		<dc:creator>Chris Danielson</dc:creator>
		<pubDate>Fri, 14 May 2010 17:31:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisdanielson.com/?p=70#comment-412</guid>
		<description>Yes, this works for both 3G and WiFi connections.</description>
		<content:encoded><![CDATA[<p>Yes, this works for both 3G and WiFi connections.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://www.chrisdanielson.com/2009/07/22/iphone-network-connectivity-test-example/comment-page-1/#comment-411</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Fri, 14 May 2010 17:29:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisdanielson.com/?p=70#comment-411</guid>
		<description>Will your example above work for a 3g connection?</description>
		<content:encoded><![CDATA[<p>Will your example above work for a 3g connection?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

