Page 1 of 1
resolved: C/C++ command to make a "ping" ?
Posted: Sun Apr 24, 2016 7:13 am
by davenull
is there a way to sort of "ping" an arbitrary internet TCP/IP address from a proprietary C/C++ program, perhaps
216.58.209.99
(== Google.de)
I actually only want to know if "ping 216.58.209.99" is successful, no detailed data needed, it's just a test if internet is available.
But which is a C/C++ command to make a "ping" ?
Re: C/C++ command to make a "ping" ?
Posted: Sun Apr 24, 2016 7:22 am
by asandford
Perhaps the source code to the ping command will reveal how it works.
Re: C/C++ command to make a "ping" ?
Posted: Sun Apr 24, 2016 7:33 am
by davenull
can you please be a little more specific?
I'm very new to C (just a little practical knowledge about C for Arduino Sketch), so I would need a command which works "as it is", out of the box, i.e., perhaps a lib which can be #included and then calling a function, something like
Code: Select all
#include <tcptools.h>
//...
int i = ping("216.58.209.99"); // i<=0: error, i>0: success
printf("%d \n", i);
//...
Re: C/C++ command to make a "ping" ?
Posted: Sun Apr 24, 2016 8:55 am
by r3d4
asandford wrote:Perhaps the source code to the ping command will reveal how it works.
Perhaps!
Take a look at ?
Code: Select all
https://git.busybox.net/busybox/plain/networking/ping.c
&& ||
http://lxr.free-electrons.com/source/net/ipv4/ping.c
Not that i know much , about that sort of thing =s .
Re: C/C++ command to make a "ping" ?
Posted: Sun Apr 24, 2016 9:02 am
by davenull
yes, thank you, I already found those monster codes
To be honest: I don't have the skills to understand what it is all about, it really knocks me out.
that's why I wrote
... perhaps a lib which can be #included and then calling a function, something like
Code: Select all
#include <tcptools.h>
//...
int i = ping("216.58.209.99"); // i<=0: error, i>0: success
printf("%d \n", i);
//...
Re: C/C++ command to make a "ping" ?
Posted: Sun Apr 24, 2016 9:18 am
by davenull
resolved!
A friend from another forum posted me the code how to call ping from a C program!
Thanks to all for your replies!
Re: C/C++ command to make a "ping" ?
Posted: Sun Apr 24, 2016 9:48 am
by buja
davenull wrote:resolved!
A friend from another forum posted me the code how to call ping from a C program!
Thanks to all for your replies!
Maybe you can share the solution here?
Re: resolved: C/C++ command to make a "ping" ?
Posted: Sun Apr 24, 2016 10:54 am
by davenull