通过TCP可能是广播? [英] Is broadcasting via TCP possible?

查看:495
本文介绍了通过TCP可能是广播?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写在C服务器/客户端系统,它采用BSD套接字TCP连接下。服务器是多线程的,在其自己的受体运行的每个连接。每个客户端做得很好用一到一的基础上,服务器交谈,可惜我不能想办法来实现SendToAll()函数,例如,如果客户A做一些事情,需要发送一个数据包所有客户端。我会怎么做呢?

I'm writing a server/client system in C, which uses BSD Sockets under a TCP connection. The server is multi-threaded, with each connection running in its own receptor. Each client does a good job talking with the server on a one-to-one basis, sadly I can't think of a way to implement a SendToAll() function, for instance, if client A does something that requires sending a packet to all of the clients. How would I do this?

我正在考虑在每一个受体执行队列中,任何广播被发送到那些队列;当受体发出一个新的数据包,它增加了该消息推送到分组为好,如果让任何意义。

I was considering implementing a queue in every receptor, and any broadcast gets sent to those queues; when the receptor sends out a new packet, it adds that message onto the packet as well, if that makes any sense.

但是,是的,有什么办法通过TCP播出,比如你可以通过UDP?

But yeah, is there any way to broadcast via TCP, like you can via UDP?

推荐答案

因为每个人都有说是不可能的TCP,它只是单播。然而,有可靠组播的实现,这应该给你TCP的可靠性组播。请参见维基百科,尤其是实际通用组播

As everyone has said that is not possible with TCP, it is unicast only. However there are implementations of reliable multicast, which should give you multicast with the reliability of TCP. See wikipedia, especially Pragmatic General Multicast.

这篇关于通过TCP可能是广播?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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