Hetal Vora
Hetal Vora

Reputation: 3361

Pinging an IP address from iOS code

How do you ping an IP address from your iOS app code? Is it same as trying to connect to it via NSURLConnection?

Upvotes: 3

Views: 7507

Answers (2)

benc
benc

Reputation: 2061

Are they the same,

and thus I'd be able to use NSURLConnection for both?

The simple answer (as far as your programming choices):

no

why?

ping uses ICMP, web connections use TCP.

These protocols are peers, they are not the same.

NSURLConnection makes TCP connections for HTTP and HTTPS. As best I can tell, it cannot use any peer protocol families that live on top of network addressing (v4 and v6), which is the "internet protocol or IP" of TCP/IP.

Upvotes: 0

helioz
helioz

Reputation: 910

Here is a link to apple's sample code: http://developer.apple.com/library/mac/#samplecode/SimplePing/Introduction/Intro.html

It is the same code iOS and OS X

Upvotes: 3

Related Questions