LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-06-2007, 05:01 PM   #1
ilnli
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Slackware 10.0, SUSE 9.1, RH 7, 7.3, 8, 9, FC2
Posts: 413

Rep: Reputation: 32
ping code


Can anyone give me the easy code of ping command can I need it to see whether a machine is up or down in my code, I've found loads of ping code but all of them are very large and complex I need a simple one that can do the task.

Please Help,


Regards,
Imran
 
Old 08-06-2007, 05:05 PM   #2
ilnli
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Slackware 10.0, SUSE 9.1, RH 7, 7.3, 8, 9, FC2
Posts: 413

Original Poster
Rep: Reputation: 32
or is there any library or function in C that can do the task of ping then please let me know.

thank you.

regards,
Imran
 
Old 08-06-2007, 08:44 PM   #3
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
The simplest ping program you're likely ever to find is at

http://www.unpbook.com/src.html

Hope this helps.
 
Old 08-07-2007, 05:42 PM   #4
ilnli
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Slackware 10.0, SUSE 9.1, RH 7, 7.3, 8, 9, FC2
Posts: 413

Original Poster
Rep: Reputation: 32
is there any library/systemcall that I can use to accomplish a ping ?
 
Old 08-08-2007, 10:34 AM   #5
rstewart
Member
 
Registered: Feb 2005
Location: Sunnyvale, CA
Distribution: Ubuntu
Posts: 205

Rep: Reputation: 38
Why don't you look at the Linux source for the ping command? Basically, it is a very simple ICMP echo request/echo response.
 
Old 08-08-2007, 05:08 PM   #6
ilnli
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Slackware 10.0, SUSE 9.1, RH 7, 7.3, 8, 9, FC2
Posts: 413

Original Poster
Rep: Reputation: 32
I've looked at it its a bit kind of complex code so I was thinking that instead of copying that whole code in my program there might be a library available for that.
 
Old 08-08-2007, 07:50 PM   #7
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
Pining a system via a network connection is not a simple task this is why the examples you are seeing are complicated.


As far as I know there is no system library that can accomplish this ( it is worth noting that there very well might be one on some exotic system) You can of course always write your own library.

or just use the system function but its not recommended.
 
Old 08-08-2007, 09:04 PM   #8
ilnli
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Slackware 10.0, SUSE 9.1, RH 7, 7.3, 8, 9, FC2
Posts: 413

Original Poster
Rep: Reputation: 32
ok thanks guys I'll use the existing code in my project.

thank you all
 
Old 08-09-2007, 01:36 AM   #9
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
To avoid trouble, make sure that you comply with the license terms accompanying any code you borrow.

Just a thought.
 
Old 08-09-2007, 07:34 AM   #10
ilnli
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Slackware 10.0, SUSE 9.1, RH 7, 7.3, 8, 9, FC2
Posts: 413

Original Poster
Rep: Reputation: 32
right, thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting 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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange Ping Issue - Can't ping localhost but can ping others on LAN code_slinger Linux - Networking 15 03-30-2015 02:39 PM
ping source code in linux fastian Linux - Networking 2 02-01-2005 07:07 AM
ping source code????? blizunt7 Linux - Networking 7 11-21-2004 07:47 PM
Where can I find compilable/executable Ping source code johnsont Programming 3 09-12-2003 12:20 PM
Where can I find the Linux Ping source code? johnsont Programming 1 09-08-2003 02:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration