Start New Discussion within our Software Development Community

Here is my Prob- we have a main router from which we use a distributor or hub for internet connection distribution, ever computer connected automatically obtains IP address of format say - 180.50.50.xxx to access net connection.

if any connected computer has different IP format than the given one, it cannot access internet.

suppose my IPaddress is - 180.50.50.100
so all the IPs connected to my local network are of type- 180.50.50.xxx

if I want to view all connected IP address of computer that have internet connection

imports Net.Dns

Dim IP as string
IP=GetHostByName(GetHostName).ToString.SubString(GetHostByName(GetHostName).LastIndexOf(".")+1)
'This gets my IP address and returns substring string IP as "180.50.50"
for i=0 to 255
if ping(IP + "." + i.ToString)
MsgBox ("IP FOUND " + IP + "." + i.ToString)
End if
next

but it takes too long to ping all IPs from 0 to 255
is there any other way in which I can see all Connected IPs even of those computer which are not accessing internet from my local network?

try this

Imports System.Net

Public Shared Function GetAllIP(Optional ByVal args As String() = Nothing) As Collection

        Dim strHostName As New String("")
        Dim col = New Collection
        ' Getting Ip address of local machine...
        ' First get the host name of local machine.
        strHostName = Dns.GetHostName()
        Console.WriteLine("Local Machine's Host Name: " + strHostName)

        ' Then using host name, get the IP address list..
        Dim ipEntry As IPHostEntry = Dns.GetHostEntry(strHostName)
        Dim addr As IPAddress() = ipEntry.AddressList

        Dim i As Integer = 0
        While i < addr.Length
            col.Add(addr(i).ToString())
            Console.WriteLine("IP Address {0}: {1} ", i, addr(i).ToString())
            i += 1
        End While
        Return col
    End Function
This article has been dead for over six months. Start a new discussion instead.