Netstat σε VB .net

Παρακάτω, τρέχουμε μία netstat και επιστρέφουμε το αποτέλεσμά της σε ένα textbox:

Public Class netstat

Private Sub netstat_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim builder As New System.Text.StringBuilder

Dim ipProps As System.Net.NetworkInformation.IPGlobalProperties = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties()

For Each connection As System.Net.NetworkInformation.TcpConnectionInformation In ipProps.GetActiveTcpConnections
builder.AppendFormat(“{0} -> {1} – {2}{3} “, connection.LocalEndPoint, connection.RemoteEndPoint, connection.State, Environment.NewLine)
Next

statbox.Text = statbox.Text & vbCrLf & “<———————————-Active Connections———————————>” & vbCrLf
statbox.Text = statbox.Text & vbCrLf & builder.ToString() & vbCrLf
statbox.SelectionStart = statbox.Text.Length
statbox.ScrollToCaret()
End Sub
End Class

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: