问题
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!
回答1:
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.
来源:https://stackoverflow.com/questions/6111204/how-to-specify-a-local-bond-interface-to-multicast-socket-in-haskell