Ping IP - Check host status

G

gallaczmit

Will this code give me a true view of a computer's status? All I am
looking for is to see if the computer is reachable or not.

My end goal is to get a list of IP addresses from a MS SQL Server, see
if the IP is reachable(if yes I will assume the pc is operational),
update the database with the result and generate a web page displaying
the results.

I am using port 135 because I have an all windows network and this
port should be open on all pcs (I think). I think I can also use this
to check the status of server services? - check 80 for IIS, 53 for
DNS........

Any suggestions/comments would be appreciated for this .net hack.


Imports System.Net
Imports System.Net.Sockets

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click

Dim tcpClient As New TcpClient
Dim IP As String = "192.168.0.1"
Dim Port As Int32 = "135"
Dim IPAddress As IPAddress = IPAddress.Parse(IP)

Try
tcpClient.Connect(IP, Port)
Label3.Text = "Ping is OK"
Catch err As Exception
Label3.Text = "Ping not OK"
End Try

End Sub

End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top