Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

General Discussion

Nic Huang
PLUS
Nic Huang
Courses Plus Student 10,573 Points

Server Ping with iPhone

In terminal, I PING www.google.com and I can receive the following data.

64 bytes from 74.125.203.104: icmp_seq=28 ttl=46 time=11.837 ms

But how can I achieve this in iOS, because I need the "time" data, so I can decide which domain is faster for me.

I've searched on the Internet and download Apple's sample code "SimplePing", but to no avail.

5 Answers

Scott Evans
Scott Evans
4,236 Points

Hi Nic.

Just a quick question so i can tailor my answer to exactly what you need. Do you need to perform this PING synchronously or async?

Scott.

Nic Huang
PLUS
Nic Huang
Courses Plus Student 10,573 Points

I think async is better for me. But Anyway, I only use that for deciding a faster domain.

Thank you in advance

Scott Evans
Scott Evans
4,236 Points

Hi Nic.

Ive managed to get the SimplePing working from Apple, but I'm still a bit unsure how you want to implement this on iOS. Ill try to throw up an example for you if i can.

Nic Huang
PLUS
Nic Huang
Courses Plus Student 10,573 Points

Hi Scott

All I need is the time data ( time=11.837 ms ) for domain (ex. www.google.com). I've tried use SimplePing in my iOS project. But the delegate doesn't fire at all. And I thought the delegate method would give me what I want.

Scott Evans
Scott Evans
4,236 Points

Im not sure something like the ping is what you would need. Let me investigate a little and ill get back to you!