在 Erlang 中检测 UDP 无法访问的端口

发布于 2024-12-06 14:58:25 字数 365 浏览 1 评论 0原文

我正在寻找一种方法来检测 Erlang 中传出 UDP 数据包的“端口无法访问”错误,这样我就可以急切地向应用程序报告传输层错误。即,我想捕获 ICMP 类型 3 数据包,以向更高层报告数据包尚未到达目的地。

目前我知道两种方法:

  1. 使用未记录的gen_udp:connect/3。然而,这似乎需要为每个新的目标对地址:端口打开一个新的套接字。优点是这不需要任何特权。
  2. 使用 gen_icmp ,它需要 setuid 帮助程序或打开原始套接字的功能。

我还缺少其他变体吗?

I am looking for a way to detect "port unreachable" errors for outgoing UDP packets in Erlang, so I can eagerly report transport layer errors to the application. I.e, I want to capture ICMP type 3 packets to report to the higher layers that packet have not reached the destination.

Currently I know about two approaches:

  1. Use undocumented gen_udp:connect/3. However, it seems like this requires opening a new socket for every new destination pair address:port. The advantage is that this does not require any privileges.
  2. Use gen_icmp which requires either setuid helper or capabilities to open raw sockets.

Are there any other variants I am missing?

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

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

发布评论

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

评论(1

狼性发作 2024-12-13 14:58:25

procket 可能就是您正在寻找的东西,但我自己从未使用过它。它是对低级套接字 API 的绑定,因此它允许您使用底层 API 支持的所有协议。我只是引用它的自述文件,所以请持保留态度。

procket might be what you're looking for, but I've never used it myself. It's a binding to the low-level socket API, therefore it allows you to use all the protocols the underlying API supports. I'm just quoting its README, so please take it with a pinch of salt.

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