iphone - How to write a simple Ping method in Cocoa/Objective-C -


I have to write a simple ping method in Cocoa / Objective-C also have to work on the iPhone is.

I found an example that uses ICMP , will it work on the iPhone?

I have a solution by using NSNetServices on the tilt, is this a good idea?

The method requires only ping host is down or unrecoverable.

The code below seems to work in a synchronous way:

 < Code> const char * hostName = [@ "stackoverflow.com" cStringUsingEncoding: NSASCIIStringEncoding]; SCNetworkConnectionFlags Flags = 0; If (SCNetworkCheckReachabilityByName (hostname, & amp; flag) & amp; amp; amp; amp; and & amp; flag & gt; 0) {NSLog (@ "host is unreachable:% d", flags); } And {nslog (@ "host is not reachable"); }  

Note: SystemConfiguration.framework is required


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -