iphone ping command, howto implement?

68 views
Skip to first unread message

Bob

unread,
May 25, 2009, 5:46:32 PM5/25/09
to iPhone SDK Development
Hi-

Im trying to implement unix 'ping' on the iphone
but not sure how to do it?

Can someone point me in the right direction?

Jesse Tayler

unread,
May 26, 2009, 1:41:31 PM5/26/09
to iphonesdkd...@googlegroups.com
I don't think there is that much UNIX available.

what are you trying to do?

Rick R

unread,
May 25, 2009, 11:52:27 PM5/25/09
to iphonesdkd...@googlegroups.com
Short answer, you should look into the ICMP protocol, which is the protocol underlying the ping mechanism.

I'd recommend looking at existing ping code on posix systems. Gnu Ping is probably your best bet.

http://cvs.savannah.gnu.org/viewvc/inetutils/inetutils/ping/ping.c
--
"The greatest obstacle to discovering the shape of the earth, the continents, and the oceans was not ignorance but the illusion of knowledge."
- Daniel J. Boorstin

Bob

unread,
May 26, 2009, 2:52:19 PM5/26/09
to iPhone SDK Development

On May 25, 8:52 pm, Rick R <rick.richard...@gmail.com> wrote:
> Short answer, you should look into the ICMP protocol, which is the protocol
> underlying the ping mechanism.
>
> I'd recommend looking at existing ping code on posix systems. Gnu Ping is
> probably your best bet.
>
> http://cvs.savannah.gnu.org/viewvc/inetutils/inetutils/ping/ping.c

Thanks Rick, Ill have a look.

Jesse, trying to integrate some ping features into an app.

I was thinking that NSNetService would be used, but ping is
based on the 'echo' service. Thinking about it all, I probably
could write my own client to do the work, but Ill have a look
at the ping source code.

Thanks

Jim W

unread,
May 27, 2009, 5:56:30 PM5/27/09
to iphonesdkd...@googlegroups.com
Depending on your needs, you could just use popen() to execute ping and capture the output. I can provide an example if you need.

Bob

unread,
May 30, 2009, 12:00:51 AM5/30/09
to iPhone SDK Development


On May 27, 2:56 pm, Jim W <j...@vaelek.com> wrote:
> Depending on your needs, you could just use popen() to execute ping and
> capture the output. I can provide an example if you need.
>

Thanks Jim. No at the moment I know how to use popen.
I didnt know I could use unix calls on the iphone though.
To what extent are unix calls available under iphone?
Is there a list somewhere or is it basically most of them?

thanks

Bob

unread,
Jun 8, 2009, 1:45:05 AM6/8/09
to iPhone SDK Development
Well Ive run into another problem or two with trying to do
ping on the iphone. There is no ping executable to call.
It works under sim mode because ping exists on the local
machine, but not on the iphone. If I try to write my own
ping code, socket gives me operation not permitted, which
apparently has to do with needing to be root (I think, not 100% sure).
setuid(0) gives me operation not permitted also.

Does anyone know how I can build an executable for
the iphone, include it in my package and set the sticky
bit for the former problem? I mean I know how to use
chmod to do it, but Im asking if this approach would work?

Im probably going to give this a try next but Id appreciate
any comments or experience with this.

Thanks

Jesse Tayler

unread,
Jun 8, 2009, 12:15:00 PM6/8/09
to iphonesdkd...@googlegroups.com
Ok, I have to ask - what are you really trying to do here?

Surely you don't really need to create ICMP traffic via iPhone?

You're just going down the wrong path here, let us know what your goal
is and I'm sure someone can advise you best on how to get the job done
without trying things that just won't work.

It is likely a few lines of code that can do whatever your end goal is
here.

Bob

unread,
Jun 8, 2009, 1:13:08 PM6/8/09
to iPhone SDK Development
Im creating my own ping app and other network utilities.
Yes I know others are out there, Im creating my own
for personal and my business use.
Reply all
Reply to author
Forward
0 new messages