1

コンピューターである localhost のポート 57875 が閉じているかどうかを確認しようとしています。これが私がこれまでに持っているコードです:

Try
        Dim checkPort As TcpClient = New TcpClient("localhost", 57875)
    Catch ex As Exception
        MsgBox("WARNING: Port 57875 is not forwarded ! The game will probably encounter an error !")
    End Try

転送されても、転送されていないと思います。コードの何が問題になっていますか?

4

1 に答える 1

1

ここに例があります:

Dim host As String = "localhost"

Dim port As Integer = 57875

Dim addr As IPAddress = DirectCast(Dns.GetHostAddresses(host)(0), IPAddress)

Try   

    Dim tcpList As New TcpListener(addr, port)   
    tcpList.Start()

Catch sx As SocketException
  'Catch exception - No available port
End Try
于 2012-11-22T15:48:07.490 に答える