通过Java发送UDP数据包

发布于 2024-09-14 18:21:01 字数 157 浏览 4 评论 0原文

我正在尝试通过笔记本电脑的以太网电缆将 UDP 数据包从我的 PC 发送到 FPGA。我一直在使用Java的DatagramPacket和DatagramSocket来发送UDP数据包。但是,这些数据包只会通过我的笔记本电脑的无线接口发送。如何指定数据包应通过我的以太网接口?

谢谢。

I'm trying to send UDP packets from my PC to an FPGA via my laptop's ethernet cable. I've been using Java's DatagramPacket and DatagramSocket to send the UDP packets. However, these packets will only send over my laptop's wireless interface. How can I specify that the packets should go through my ethernet interface?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不弃不离 2024-09-21 18:21:01

当然,您可以按照x4u的建议将DatagramSocket绑定到特定接口,但是如果您的UDP数据包发送到不正确的接口上,我宁愿假设您的操作系统网络堆栈的路由表配置不正确,因此操作系统相信您的 FPGA 可以通过 WLAN 接口而不是以太网接口访问。

You may of course bind your DatagramSocket to a specific interface as x4u suggested, but if your UDP packets are sent on an incorrect interface, I would rather assume that the routing table of your operating system's network stack is configured incorrectly, so that the operating system believes your FPGA to be reachable through the WLAN interface instead of your ethernet interface.

暖风昔人 2024-09-21 18:21:01

如果使用 public DatagramSocket(int port, InetAddress laddr) 构造函数来创建 DatagramSocket 并将其传递给本地以太网接口的 InetAddress,也许它会起作用。

Maybe it works if use the public DatagramSocket(int port, InetAddress laddr) constructor to create your DatagramSocket and pass it the InetAddress of your local ethernet interface.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文