且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

发送/接收UDP数据包的帮助-C套接字

更新时间:2022-01-21 08:12:22

在侦听器中,我认为您需要设置

In the listener, I think you need to set

listeningMc_req.imr_interface.s_addr = htonl(INADDR_ANY);

...,因为这也是绑定套接字的接口.根据您是否在单个主机上运行所有内容,您可能需要考虑回送接口,并绑定到INADDR_ANY即可做到这一点.

... since that is also the interface on which you bind the socket. Depending on whether you run everything on a single host, you might need to consider the loopback interface and binding to INADDR_ANY will do that.