UPNP を使用してポートを開こうとしています。mono.nat を使用しています。
これは私のコードで、単純で動作するはずですが、for each で「エラー 402: 無効な NewPortMappingIndex」がスローされます。「デバイス」の他のさまざまな機能は、GetExternalIP のように機能します。
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler NatUtility.DeviceFound, AddressOf DeviceFound
NatUtility.StartDiscovery()
End Sub
Private Sub DeviceFound(ByVal sender As Object, ByVal e As Mono.Nat.DeviceEventArgs)
Debug.WriteLine("Found")
Dim device As INatDevice = e.Device
Debug.WriteLine(device.GetHashCode)
For i = 0 To device.GetAllMappings.Length - 1
Dim _PortMap As Mono.Nat.Mapping = device.GetAllMappings(i)
ListBox1.Items.Add(_PortMap.Description & " | " & _PortMap.PrivatePort & " | " & _PortMap.Protocol & " | " & _PortMap.PublicPort)
Next
End Sub
また、ファイアウォールをオフにしたり、干渉している可能性のある他のものをオフにしたりしました。また、ルーターが UPNP 対応であることも知っています。