如何在Haskell中指定组播套接字的本地绑定接口? [英] How to specify a local bond interface to multicast socket in Haskell?

查看:186
本文介绍了如何在Haskell中指定组播套接字的本地绑定接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过Network.Multicast软件包,但它确实有效,但是,我找不到一种方法来指定本地绑定接口(bond0或bond1等)到多播套接字。我知道在C中我需要使用ioctl将绑定转换为struct sockaddr_in,然后将此结构提供给IPPROTO_IP系列的setsockopt下的IP_MULTICAST_IF选项,但我不确定如何在Haskell中执行此操作。有人能帮忙吗?感谢!

解决方案

在network-multicast [1]的源代码中,我看到了在setInterface函数中设置ip_multicast_if的调用。它总是在您传入的主机字符串中调用 inet_addr 结果。



[1] http://hackage.haskell .org / packages / archive / network-multicast / 0.0.6 / doc / html / src / Network-Multicast.html 我会想象你需要编写你自己的ffi绑定和函数来做你想做的事情。但是,根据网络多播中的代码,这应该很简单,我相信一旦你这样做了,它将成为图书馆的补丁。


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!

解决方案

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.

这篇关于如何在Haskell中指定组播套接字的本地绑定接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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