UDP广播问题
我正在尝试做这样的事情。同一子网中有一台服务器和多个客户端。客户端将向服务器发送一些内容,服务器将该消息发送回子网中的所有其他客户端。所以这对我来说就像是广播。但我从来没能在 C 语言中做到这一点。如果你给我一个例子,我会很高兴。
编辑:既然是UDP,可靠性就不是问题了。这些计算机位于同一网络中,不可能丢失数据包。该程序不接收来自其他客户端的消息。这就是我必须做的。顺便说一句,谢谢。
I'm trying to do something like this. There is one server , and multiple clients in the same subnet. Clients will send something to server and server will send this message back to all the other clients in the subnet. So this looks like broadcast to me. But i never could manage to do this in C.. I'd be glad if you give me an example of this.
EDIT: Well since it is UDP , reliability is not a problem. These computers are in the same network and no packet lost is possible. That program does not recieve messages from other clients. That is what I have to do. Thanks by the way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不应该使用广播,而应该使用多播。例如,ghost 和其他通过网络的“图像磁盘备份”会使用此功能。
我已经用 java 用 MulticastSocket 发送 DatagramPacket 完成了它,如果你需要测试......
You should not use broadcast, but rather multicast. This is used for instance by ghost and other "images disk backup" over network.
I have done it in java with a MulticastSocket sending a DatagramPacket, if you need a test...
【这篇文章的内容已移至问题中。】
[The contents of this post have been moved to the question.]