Get all ip addresses of the computers connected to LAN

  • Thread starter Thread starter Lucky
  • Start date Start date
L

Lucky

hi there!!!
very much newbie to socket progammin in .net. i've try the DNS class to
get the ip addresses but it always returns 1 ip that of my pc though i
got 50 PCs connected to the LAN. i tried everywhere so if anyone have
code for getting all the ip addresses of the PCs. plz copy paste here
so that i can try that out. Plz dont only give suggestions. put some
code. which can b helpful to me. i've already tried many suggestion.
plz dont mind but now i'm frustrate
 
Lucky said:
got 50 PCs connected to the LAN. i tried everywhere so if anyone have
code for getting all the ip addresses of the PCs

If You get Mask or Broadcast You may try to caclulate the whole range of
IP's that Yours computer belong to. Than if Bcast is not huge (ie. is
correctly configured) You may want to ping all the IPs and check if they are
alive.

Eg. Yours IP 192.168.1.20
Mask 255.255.255.192
then addresses in Your network are most probably in a range 192.168.1.0 -
192.168.1.63

RGDS PSG
 
hi there!!!
very much newbie to socket progammin in .net. i've try the DNS class to
get the ip addresses but it always returns 1 ip that of my pc though i
got 50 PCs connected to the LAN. i tried everywhere so if anyone have
code for getting all the ip addresses of the PCs. plz copy paste here
so that i can try that out. Plz dont only give suggestions. put some
code. which can b helpful to me. i've already tried many suggestion.
plz dont mind but now i'm frustrate

It going to be something like ARP, your own machine will have an ARP cache.
Look into the protocol and see if there's a broadcast that can be sent to
resolve all machines.
 
I cannot at this moment verify if this works, but I found this with a simple
google search using the keywords "csharp finding all computers network":

Link is here (watch for wordwrap):
http://groups.google.co.uk/groups?hl=en&lr=&[email protected]

Text from that article:

You can do this using ADSI in the System.DirectoryServices namespace. See
sample C# code below.

System.DirectoryServices.DirectoryEntry entryPC;
entryPC = new System.DirectoryServices.DirectoryEntry();
entryPC.Path = "WinNT://YourDomainname"
foreach(DirectoryEntry child in entryPC.Children)
{
if(child.SchemaClassName == CONST_COMPUTER)
MessageBox.Show(child.Name);

}
[end quote]

HTH.
 
Back
Top