01.
Private
Sub
Timer1_Tick(
ByVal
sender
As
System.
Object
, _
02.
ByVal
e
As
System.EventArgs)
Handles
Timer1.Tick
03.
04.
counter = counter + 1
05.
TextBox2.Text = counter
06.
host = TextBox1.Text
07.
port = TextBox2.Text
08.
09.
10.
11.
Dim
hostadd
As
System.Net.IPAddress = _
12.
System.Net.Dns.GetHostEntry(host).AddressList(0)
13.
Dim
EPhost
As
New
System.Net.IPEndPoint(hostadd, port)
14.
Dim
s
As
New
System.Net.Sockets.Socket(_
15.
System.Net.Sockets.AddressFamily.InterNetwork, _
16.
System.Net.Sockets.SocketType.Stream, _
17.
System.Net.Sockets.ProtocolType.Tcp)
18.
Try
19.
s.Connect(EPhost)
20.
Catch
21.
End
Try
22.
If
Not
s.Connected
Then
23.
ListBox1.Items.Add(
"Port "
+ port.ToString +
" is not open"
)
24.
Else
25.
ListBox1.Items.Add(
"Port "
+ port.ToString +
" is open"
)
26.
ListBox2.Items.Add(port.ToString)
27.
End
If
28.
Label3.Text =
"Open Ports: "
+ ListBox2.Items.Count.ToString
29.
End
Sub