我正在尝试打开端口,使用UPNP来完成此操作,我正在使用mono.nat
这是我的代码,它很简单,应该可以工作,但它在for each上抛出了“error402: Invalid NewPortMappingIndex”。"device“的各种其他功能与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。
发布于 2013-09-26 15:02:19
这似乎循环了太多次:
对于i=0到device.GetAllMappings.Length
https://stackoverflow.com/questions/19020786
复制相似问题