Make list of IP's inside Range (2)

From: J. Codac (ebayaccount_at_xs4all.nl)
Date: 05/27/04


Date: Thu, 27 May 2004 12:00:26 +0200

The other thread was a little full, so I started a new one:

for those how read this the first time, my orginal question is on the bottom

Hi people,

I'm almost there. I've writed the folowing code:

procedure TForm1.Button1Click(Sender: TObject);
var
  a, b: TInAddr;
  I1, I2, I: Integer;
begin
  Listbox1.Clear;
  a.S_addr := Inet_addr(PChar(Edit1.Text));
  b.S_Addr := inet_addr(PChar(Edit2.Text));
  I1 := ntohl (a.S_addr);
  I2 := ntohl (b.S_addr);
  for I:=I1 to I2 do
  begin
     Listbox1.Items.Add (IntToStr(I));
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  I, I2: Integer;
  a: TInAddr;
  P: PChar;
  lI: LongInt;
begin
  for I := 0 to Listbox1.Count-1 do
  begin
    I2 := StrToInt (Listbox1.Items.Strings[i]);
    a.S_addr := ntohs (I2);
    P := inet_ntoa (a);
    Listbox2.Items.Add(Pchar(P));
  end;
end;

In Edit1 and Edit2, I define the IP Range
Listbox1 Shows a bounch of numbers of the IP Range
Listbox2 Shows the numbers converted back to IP's

Now the problem: The data displayed in listbox2 is not right!:

- I give the following IP-range 10.0.0.1 until 10.0.0.10

now I get the following data back:

0.1.0.0
0.2.0.0
0.3.0.0
0.4.0.0
0.5.0.0
0.6.0.0
0.7.0.0
0.8.0.0
0.9.0.0
0.10.0.0

Can anybody tell me what I'm doing wrong????

thanks!@@

----------Orginal message-------------
Hello all,

I need to scan a IP-Range for Information. for example range 10.0.0.1 -
10.0.0.254. I need to get information from each host seperate. So I need to
make a list of all possible IP's within specified range. for example:

10.0.0.1
10.0.0.2
10.0.0.3

and so on

does anybody know how to do this?

thanks!@!@
--------End Orginal message---------------


Quantcast