开发者

recvfrom stuck on one interface

I'm using recvfrom to receive muticast messages from the network. There are two network interfaces on the system and recvfrom only receives from the first interface. When th开发者_JS百科e 2nd interface is functional, recvfrom is blocked indefinitely and only receives a packet after switching to the 1st interface. SO_REUSEADDR is used in set options while opening the socket.Removing this also doesn't help. Any ideas?? I'm stuck.


I'd create one socket for each interface and bind explicitly to the interface rather than using INADDR_ANY.

The problem with using INADDR_ANY is that once you have received a datagram the socket is probably implicitly bound to the interface that the datagram arrived on, IMHO it has to be so that you can send a response from the interface that the datagram arrived on...


I was able to resolve this by using DROP_MEMBERSHIP and ADD_MEMBERSHIP on the multicast socket whenever network interface changed. I also had to make changes to the socket library, where initially it used to return the first available multicast capable interface(even though no IP is assigned) to return that interface which has multicast enabled and also has a IP address assigned.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜