ok, i am trying to creat my own ip scanner just like angry ip scanner. i like it, but i wanted to add something that i felt needed to be added such as your own ip so when i am on another network i dont have to do an ip config. well i have it all set up and work, it is just it is very slow. i mean it takes 10 seconds just to do 10 ip addresses. i noticed when angry does it, it has 63 threads running at once to speed this process up. i have tried to speed it up as much as possible without threads by doing less calculating in the for statements and whatnot, but it still isnt fast enough. i am trying to figure out how to do threading myself like angry. here is the code i am excuting, i know its very noobish code and all, but i havent programmed in like 2 years now so i am just getting back into it. so if someone could help me with the threading part, i would appreciate it very much.
varibles: F1-F4 are ip from and T is too
varibles: F1-F4 are ip from and T is too
Code:
private void button3_Click(object sender, EventArgs e)
{
Ping pinger = new Ping();
PingOptions options = new PingOptions();
options.DontFragment = true;
string data = "aaaaaaaaaaaaaaaaaaa";
byte[] buffer = Encoding.ASCII.GetBytes(data);
int timeout = 120;
string begAddy = F1.Text + "." + F2.Text + "." + F3.Text + ".";
int f4int = Convert.ToInt32(F4.Text);
int t4int = Convert.ToInt32(T4.Text);
IPAddress ipaddy;
for (int z = f4int; z <= t4int; z++)
{
ipaddy = IPAddress.Parse(begAddy + z);
PingReply pingRep = pinger.Send(ipaddy, timeout, buffer, options);
if (pingRep.Status == IPStatus.Success)
{
IPHostEntry temp = new IPHostEntry();
temp = Dns.GetHostEntry(ipaddy);
textBox1.AppendText("Address: " + pingRep.Address.ToString() + ": " + temp.HostName.ToString() + "\r\n");
}
progressBar2.Increment(2);
}
}