hello there!!
Im doing a code for 'ping' command.
can anyone tell me how to terminate the 'ping' process without using the ctrl-c.
I mean is there any way that we can define/fixed the send packet in 'ping'?
anyway, this is my code look like
Code:
#include <iostream>
#include <string>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
using namespace std;
static string host;
static string ping_2;
void ping()
{
system("clear");
cout << "Host: ";
cin >> host;
system (("ping " + host).c_str());
cout << endl;
cout << "Ping another host? Yes or No: ";
cin >> ping_2;
if (ping_2 == "Y" || ping_2 == "y")
{
system("clear");
ping();
}
else if (ping_2 == "N" || ping_2 == "n")
{
system("exit");
}
}
int main()
{
ping();
return(0);
}
attention from anyone will really appreciate
Thanks in advance!