I am starting a project of my own (and learning C++ at the same time...bad idea? I dont think so yet...lol) I got my program to successfully scan a custom netmask, but it is REALLY slow. I want my program to do something similar to nmap -sP xxx.xxx.xxx.xxx-xxx. Any ideas on how to speed it up? Such as pinging more than one IP at a time...
Code:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <sstream>
using namespace std;
int ip42;
string ip1, ip2, ip3, ip4, ipaddr;
int main()
{
cout << endl << "Enter part 1: ";
cin >> ip1;
cout << endl << "Enter part 2: ";
cin >> ip2;
cout << endl << "Enter part 3: ";
cin >> ip3;
cout << endl << "Enter part 4: ";
cin >> ip4;
while(ip42 < 255){
ipaddr = string("ping -c 1 ").append(ip1);
ipaddr = string(ipaddr).append(ip2);
ipaddr = string(ipaddr).append(ip3);
ipaddr = string(ipaddr).append(ip4);
system(ipaddr.c_str());
ip42 = atoi(ip4.c_str());
ip42 += 1;
stringstream output;
output << ip42;
output >> ip4;
}
}