davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

resolved: C/C++ command to make a "ping" ?

Sun Apr 24, 2016 7:13 am

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" ?
Last edited by davenull on Sun Apr 24, 2016 9:18 am, edited 1 time in total.
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

asandford
Posts: 1998
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: C/C++ command to make a "ping" ?

Sun Apr 24, 2016 7:22 am

Perhaps the source code to the ping command will reveal how it works.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: C/C++ command to make a "ping" ?

Sun Apr 24, 2016 7:33 am

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);
   //... 
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
r3d4
Posts: 982
Joined: Sat Jul 30, 2011 8:21 am
Location: ./

Re: C/C++ command to make a "ping" ?

Sun Apr 24, 2016 8:55 am

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 .

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: C/C++ command to make a "ping" ?

Sun Apr 24, 2016 9:02 am

yes, thank you, I already found those monster codes :shock:
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);
   //... 
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: C/C++ command to make a "ping" ?

Sun Apr 24, 2016 9:18 am

resolved!
A friend from another forum posted me the code how to call ping from a C program!
Thanks to all for your replies!
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
buja
Posts: 567
Joined: Wed Dec 31, 2014 8:21 am
Location: Netherlands

Re: C/C++ command to make a "ping" ?

Sun Apr 24, 2016 9:48 am

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?

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: resolved: C/C++ command to make a "ping" ?

Sun Apr 24, 2016 10:54 am

#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

Return to “C/C++”