Hi all,

I'm wondering how I can get the name of a process on a port. During our install I am calling the following code to see if a user entered port is open. If not, I want to get information on the process tied to the port because if let's say the name is a certain value, I'll allow the entry...

 

Dim hostname As String = "127.0.0.1" 
Dim port As Integer
Dim ipa As IPAddress = DirectCast(Dns.GetHostAddresses(hostname)(0), IPAddress) 
Dim sock As New System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp)     'Port will have a value grabbed from the running installer (Session.Item)...  sock.Connect(ipa, port)  If sock.Connected = True Then     'Connection in use...port not available      session.Item("PORT_VALID") = "" End If sock.Close()

As is, the code runs OK for me in that if the port is in use, there is notification. I would like to do a second check to see what process is running on the selected port. If is is the process that is intended for this port, I want to allow the entry even though it is in use.

Any help is Greatly appreciated!!

0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Answers


  • I was looking for VB.NET code to do it, but I may just have to call commands contained in the linked article, create text files, read the results, etc.
Please log in to comment
Answer this question or Comment on this question for clarity