Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > C/C++ ICMP Library

C/C++ ICMP Library
Thread Tools
Mac Enthusiast
Join Date: Nov 2002
Location: over yonder
Status: Offline
Reply With Quote
Oct 18, 2004, 01:20 AM
 
Is anyone aware of a C/C++ ICMP library for use on *NIX?

I'm looking to write just a basic command line program that will ping some pre-defined servers and was wondering if I could simplify everything by not having to re-write the ping utility.

Thanks for any help.
chown -R us:us yourbase

Dissent is not un-American.
     
Senior User
Join Date: Feb 2001
Location: Deer Crossing, CT
Status: Offline
Reply With Quote
Oct 18, 2004, 11:12 AM
 
Why not call the ping CLI from your program? Otherwise, can you use the <net/inet.h> headers? <net/inet.h> might not be the correct name, it's been awhile since I did 'net access.
20" iMac G5! :D AND MacBook 1.83GHz!
Canon Digital Rebel Kit + 75 - 300mm lens. Yum Yum! :D
Check out my OS X Musical Scales program
     
Mac Enthusiast
Join Date: Nov 2002
Location: over yonder
Status: Offline
Reply With Quote
Oct 18, 2004, 11:53 AM
 
Originally posted by PBG4 User:
Why not call the ping CLI from your program? Otherwise, can you use the <net/inet.h> headers? <net/inet.h> might not be the correct name, it's been awhile since I did 'net access.
It's the <netinet/in.h> header, but does that contain any ICMP objects or functions? It provides basic connectivity, but I'm looking for ping/traceroute, etc.

Also, how do you call the CLI from C++? I've never done that before.
chown -R us:us yourbase

Dissent is not un-American.
     
Senior User
Join Date: Feb 2001
Location: Deer Crossing, CT
Status: Offline
Reply With Quote
Oct 18, 2004, 12:28 PM
 
Originally posted by fromthecloud:
It's the <netinet/in.h> header, but does that contain any ICMP objects or functions? It provides basic connectivity, but I'm looking for ping/traceroute, etc.

Also, how do you call the CLI from C++? I've never done that before.
I've only done it from C, not C++ but that was awhile ago. I know I used some library, maybe try typing "man 3 intro" on a command line (without the quotes) to dig into the libraries included with OS X?

[Addendum]
I knew there were libraries to do this!
Check out the information located here: --> http://www.cs.cf.ac.uk/Dave/C/node22...00000000000000

Check out the execl() and system() calls and see if these will do what you need. Of course you may need to set up some kind of stream (I think?) if you want to get the called program's output (in your case, the 'ping' command).

Check out this section as well: --> http://www.cs.cf.ac.uk/Dave/C/node23...00000000000000

This uses popen() and this may be what you need. There's some sample code here.

This is the main page for this site: --> http://www.cs.cf.ac.uk/Dave/C/CE.html <-- Very good starting C stuff.

Let me know if this helps.
20" iMac G5! :D AND MacBook 1.83GHz!
Canon Digital Rebel Kit + 75 - 300mm lens. Yum Yum! :D
Check out my OS X Musical Scales program
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:16 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2