如何在 Haskell 中指定多播套接字的本地绑定接口?
我已经尝试过 Network.Multicast 包并且它确实有效,但是,我找不到为多播套接字指定本地绑定接口(“bond0”或“bond1”等)的方法。我知道在 CI 中需要使用 ioctl 将 bond 转换为 struct sockaddr_in,然后将此结构提供给 setsockopt 的 IPPROTO_IP 系列下的 IP_MULTICAST_IF 选项,但我不确定如何在 Haskell 中执行此操作。谁能帮忙解决这个问题吗?谢谢!
I have tried Network.Multicast package and it does work, however, I cannot find a way to specify a local bond interface ("bond0" or "bond1" etc) to the multicast socket. I know in C I need to use ioctl to convert the bond into a struct sockaddr_in, then feed this struct to IP_MULTICAST_IF option under IPPROTO_IP family of setsockopt, but I am not sure how to do this in Haskell. Can anyone help with this? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在网络多播 [1] 的源代码中,我看到在 setInterface 函数中调用了 set ip_multicast_if 。它总是使用您传入的主机字符串上的
inet_addr
的结果进行调用。[1] http://hackage.haskell.org/packages/archive/network-multicast/0.0.6/doc/html/src/ Network-Multicast.html
我想您需要编写自己的 ffi 绑定和函数来完成您想要的操作。但根据网络多播中的代码,这样做应该很简单,而且我确信一旦你这样做,这将是库的一个受欢迎的补丁。
In the source of network-multicast [1] I see a call to set ip_multicast_if in the setInterface function. It is always called with the result of
inet_addr
on the host string you pass in.[1] http://hackage.haskell.org/packages/archive/network-multicast/0.0.6/doc/html/src/Network-Multicast.html
I would imagine that you need to write your own ffi bindings and function to do what you want. But it should be straightforward to do so based on the code in network-multicast, and I'm sure that once you do so it would be a welcome patch to the library.