Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.Net] Local/Remote TCP info from process [Source]
#4
I hope someone is still monitoring this thread. I'm trying to get a process name if a port is found to be in use. I'm hoping someone can help me leverage the information here to get the job done.

My current code (installer custom action) works to detect if the port is in use, but I want to take it a step further and get the process name of the port user. If is a certain value I will allow the use of that port in the install dialog. If not, I will notify that port is in use.

Anyway, here's my code...

Code:
Dim hostname As String = "127.0.0.1"
Dim port As Integer
Dim ipa As IPAddress = DirectCase(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)

sock.Connect(ipa, port)
If sock.Connected = True Then
     session.item("PORT_VALID") = "" 'Property value returned to installer.
End If

sock.Close

Like I said, this code works pretty well or so it seems. I just want to add a layer to it to check the process by PID I guess, grab the name and if = to or contains "MyValue" then allow the in use port to be selected or used during the install.

I hope someone can help.
Reply


Messages In This Thread
RE: [VB.Net] Local/Remote TCP info from process [Source] - by superfreak3 - 07-06-2012, 01:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [VB.NET] Remote desktop viewer [VB.NET] TalishHF 13 11,567 05-25-2013, 03:21 AM
Last Post: Imaking31
  Free Advanced Port Scanner SOURCE [ VB.NET ] Filefinder 6 5,747 01-22-2013, 04:27 AM
Last Post: TalishHF
  [VB.NET]Console app Menu example (amortization calculator)[Source] KoBE 8 8,168 12-28-2012, 06:55 AM
Last Post: mouse719
  [VB.NET] Get Region Info [Source] ƃu∀ ıʞƃu∀ 0 1,252 11-28-2012, 04:38 AM
Last Post: ƃu∀ ıʞƃu∀
  [Source] List Process'/Kill Process ♱ RedTube ♱ 3 1,819 11-25-2012, 10:39 PM
Last Post: ƃu∀ ıʞƃu∀

Forum Jump:


Users browsing this thread: 1 Guest(s)