UDP无法通过互联网VB.NET工作 [英] UDP not working over the internet VB.NET

查看:84
本文介绍了UDP无法通过互联网VB.NET工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在通过互联网发送UDP数据包时遇到问题。我按照 https://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient(v = vs.110)的.aspx CS- save-lang = 1& cs-lang = vb#code-snippet-2 我能够在本地主机上发送UDP数据包(客户端和服务器在同一台计算机上)。我还能够使用来自路由器的私有IP(192.168.xxx.xxx)将UDP数据包发送到同一网络上的其他计算机。但是当我想通过互联网发送UDP数据包时,数据包将无法到达目标计算机。当我搜索可能是什么原因的Google搜索时,我发现了以下内容:



1.要通过互联网访问计算机,您必须连接到 public计算机的IP地址。

2.您需要在路由器上启用端口转发,以将公共IP地址上的传入数据包重定向到计算机的专用IP地址



我做了一切,但仍然拒绝工作。我发送UDP数据包到我的互联网的公共IP地址,我也做了端口转发ony路由器。虽然我不太确定我所做的设置是否正确,但是端口转发设置有四个必填字段,我设置如下:

远程主机:我把它留空了

远程端口范围:54321-54321

本地主机:192.168.1.13(接收计算机)

本地端口:54321

协议:TCP / UDP



我保存了设置。因此,当我在发送计算机上发送UDP数据包时,它没有到达接收计算机。我不知道为什么。请帮帮我。

I am having problem sending UDP packets over the internet. I followed the example found at https://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2 and I was able to send UDP packets on the local host (client and server are on the same computer). I was also able to send UDP packets to other computers on the same network using the private IP from router (192.168.xxx.xxx). But when I want to send the UDP packet over the internet, the packets will not get to the destination computer. When I do a google search on what might be the cause, I discovered the following:

1. To access a computer over the internet, you must connect to the "public" IP address of the computer.
2. You need to enable port forwarding on your router to redirect incoming packets on the public IP address to the computer's private IP address

I did everything and still, it refuse to work. I am sending out UDP packets tothe public IP address of my internet and I have also done port forwarding ony router. Although I am not too sure if the setting I did was correct, but there are four required fields for the port forwarding settings which I set as follows:
Remote host: I left it blank
Remote port range: 54321-54321
Local host: 192.168.1.13 (the receiving computer)
Local port: 54321
Protocol: TCP/UDP

And I saved the settings. So, when I send out UDP packets on the sending computer, it did not arrive on the receiving computer. I don't know why. Please help me out.

推荐答案

如果您正在进行发送,则不要在您的计算机上进行端口转发。你是在接收端做的。



如果你试图在两台机器之间双向发送数据,那么BOTH必须设置端口转发到它们各自的内部IP地址和端口。





您正在向公共IP和端口组合发送数据。该地址的路由器必须将您正在使用的端口上的UDP流量转发到目标应用程序正在侦听的内部专用IP和端口。
If you're doing the sending you don't do the port forwarding on your machine. You do it on the receiving end.

If you're trying to send data in both directions between two machines, BOTH ends have to setup port forwarding to their respective internal IP addresses and ports.


You're sending data to a public IP and Port combination. The router at that address has to forward UDP traffic on the port you're using to the internal private IP and Port that your target application is listening on.


这篇关于UDP无法通过互联网VB.NET工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆