Click here to Skip to main content
12,511,553 members (45,214 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET VS2012
Hi,

I want to write a vb program to find all connected network devices to my computer.
all devices which is connected to my computer use IPv4 and am trying to find the devices IP adresses.

how can i do?

thanks

Maybe you didnt undrestand whaat i need really,
I need the a list and ip of physical devices which is connected to my computer, not the program and services of local computer
Posted 28-Dec-12 23:14pm
Updated 29-Dec-12 0:30am
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Do you really want to write it for yourself?
Since there are lots of free tools outside, able to tell you this. See Sysinternals TCPview[^] for example, or the built-in windows tool NETSTAT[^].

But it is really not complicated at all, check out this article:
http://towardsnext.wordpress.com/2009/02/09/netstat-in-c/[^]

[Update]
Here is the vb.net version of it:
Imports System
Imports System.Net
Imports System.Net.NetworkInformation
 
Module Program
	Sub Main()
		Dim ipProperties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
 
			Dim endPoints As IPEndPoint() = ipProperties.GetActiveTcpListeners()
			Dim tcpConnections As TcpConnectionInformation() = ipProperties.GetActiveTcpConnections()
 
			For Each info As TcpConnectionInformation In tcpConnections
				Console.WriteLine("Local : " & info.LocalEndPoint.Address.ToString() & ":" & info.LocalEndPoint.Port.ToString() & vbLf & "Remote : " & info.RemoteEndPoint.Address.ToString() & ":" & info.RemoteEndPoint.Port.ToString() & vbLf & "State : " & info.State.ToString() & vbLf & vbLf)
			Next
			Console.ReadLine()
	End Sub
End Module
  Permalink  
v2
Comments
MehdiFadaei 29-Dec-12 5:50am
   
Yes, i want to write because this is a part of my program.
really the code which you supported dosnt work. at the moment my compter is connected to home group via wireless and also a device is connected to my computer via ethernet port. my computer ip for wireless is 192.168.1.7 and for ethernet is 10.0.0.100
the connecterd devices to wireless: another computers: 192.168.1.2 to 6
the connected device to lan 10.0.0.241

but this program is not able to find these devices
MehdiFadaei 29-Dec-12 6:25am
   
thanks but dosnt work anymore
Zoltán Zörgő 29-Dec-12 11:06am
   
is netstat showing you what you want?
Zoltán Zörgő 29-Dec-12 12:19pm
   
As I see, your question is wrong. What you want is not the list of devices connected to your computer, you want to list the devices connected to your networks. That is something else.
A device is connected to your computer if there is any socket opened between the remote device and your machine, that is what you can list this way, and that is what you asked for.
MehdiFadaei 29-Dec-12 13:52pm
   
Really you are right, iam looking for the devices which are connected to my networks. sorry. how can i solve it?
Zoltán Zörgő 29-Dec-12 15:36pm
   
Well, that's only a little bit more difficult. You have two possibilities:
1) If your router is capable of such reports, you can ask it.
2) If you have the address range, and that is low (as I see, you have two ranges with less than 255 addresses), you can try to ping all addresses one by one supposing that the devices are responding to icmp packets. Use: http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping.aspx
2+) Here you have a little bit more delicate "nmap" like application, with c# source, you can get ideas: https://github.com/Simran/nmap-csharp
Zoltán Zörgő 31-Dec-12 3:21am
   
Any progress?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160929.1 | Last Updated 29 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100