30-05-14, 10:27 AM
تفضل أخي
كود :
Private Function TCP_Port_Open(ByVal ip As String, ByVal port As Integer) As Boolean
Dim TcpPortscan As TcpClient = Nothing
Try
'Try to connect
TcpPortscan = New TcpClient(ip, port)
' we are still here :) so this port is asumed open
Return True
Catch ex As Exception
Return False
Finally
If TcpPortscan IsNot Nothing Then TcpPortscan.Close()
End Try
End Function
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
For Each IP As String In ListBox1.Items
For Each Port As String In TextBox1.Lines
Dim PortOpen As Boolean = TCP_Port_Open(IP, Integer.Parse(Port))
If PortOpen Then
Exit For
End If
Next
Next
End Sub