2
如何檢查特定端口是否被Windows防火牆阻止,無論是在傳入連接還是傳出連接中。檢查端口是否被windows防火牆阻止
我見過的代碼示例像這樣的:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim host As String = "localhost"
Dim port As Integer = 6900
Dim addr As IPAddress = CType(Dns.GetHostAddresses(host)(0), IPAddress)
Try
Dim tcpList As New TcpListener(addr, port)
tcpList.Start()
Catch sx As SocketException
' Catch exception here if port is blocked
End Try
End Sub
但我怎麼能知道,如果拋出異常特別是因爲防火牆攔截的,而不是因爲其他套接字錯誤的?
謝謝,VB示例很棒! – MichaelS