0
我爲時鐘系統公司工作,有時無法訪問路由器和其他工具來查找網絡中的某些東西。掃描在端口9922上運行的東西的內部IP範圍VBNet
所以我做了這個,但得到的錯誤。我需要能夠掃描端口9922,TCP上的內部網絡。
Imports System.Net.Sockets
Imports System.Net
Imports System.Threading
Imports System.Text
Module Module1
Dim portStart As Integer
Dim portEnd As Integer
Dim lngPort As Long
Dim lngRange As Long
Dim txtHost1 As String
Dim txtHost2 As String
Dim txtHost As String
Dim openPorts As Integer
Dim closedPorts As Integer
Dim range As String
Dim lgnRange2 As Long
Sub Main()
Console.Write("Range Start: (For example 192.168.1.1 = 192.168.1. ")
range = Console.ReadLine()
Console.Write("Host to: Example 1 ")
txtHost1 = Console.ReadLine()
Console.Write("Host from: Example 254 ")
txtHost2 = Console.ReadLine()
Console.Write("Port: (9922 for Face Rec By default)")
portEnd = Console.ReadLine()
For lngRange = txtHost1 To txtHost2
Next
For lgnRange2 = range + lngRange
Dim myTcpClient As New TcpClient()
Try
myTcpClient.Connect(lngPort, portEnd)
Console.WriteLine("Host: " + txtHost + " : ")
Console.WriteLine(" Port " + lngPort.ToString() + " : Open :")
openPorts += 1
myTcpClient.Close()
Catch ex As SocketException
Console.WriteLine("Host: " + txtHost + " : ")
Console.WriteLine(" Port " + lngPort.ToString() + " : Closed :")
' Console.WriteLine(ex.Message)
closedPorts += 1
Console.Write(" " & openPorts.ToString & " open port(s) : ")
Console.Write(" " & closedPorts.ToString & " closed port(s) : ")
Console.Beep()
Console.Write(txtHost + " : " + portStart.ToString + " - " + portEnd.ToString + " : Scanned Sucessfully")
End Try
Next
End Sub
Public Class psAPP
Public Shared Sub Main()
End Sub
End Class
End Module
你應該提供比「所以我做了這個,但得到的錯誤已經」更多的細節 - 什麼錯誤是什麼線?運行時或編譯錯誤?等等。回顧[問]獲取更多提示。 – Mark
這行看起來不正確。對於lgnRange2 = range + lngRange'。 – Mark
對不起,遲到的迴應, –