像UDP一样广播,具有TCP的可靠性 [英] Broadcast like UDP with the reliability of TCP

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

问题描述

我正在开发一个完全在单个网络中运行的 .net 解决方案.当用户对系统进行更改时,我想发布一个公告,让其他人听到并采取相应的行动.有没有一种方法可以让我们广播出这样的消息(就像 UDP 会让你做的那样),同时保持有保证的传输(如 TCP)?

I'm working on a .net solution that is run completely inside a single network. When users make a change to the system, I want to launch an announcement and have everyone else hear it and act accordingly. Is there a way that we can broadcast out messages like this (like UDP will let you do) while keeping guaranteed delivery (like TCP)?

这是在一个小型网络(30 多个客户端)上,如果这会有所作为的话.

This is on a small network (30ish clients), if that would make a difference.

推荐答案

几乎所有游戏都需要 UDP 的快速反应特性(在较小程度上,无连接特性)和 TCP 的可靠性.他们所做的是在 UDP 之上构建自己的可靠协议.这使他们能够将数据包突发到任何地方,并且还可以选择使它们可靠.

Almost all games have a need for the fast-reacting properties (and to a lesser extent, the connectionless properties) of UDP and the reliability of TCP. What they do is they build their own reliable protocol on top of UDP. This gives them the ability to just burst packets to whereever and optionally make them reliable, as well.

可靠的数据包系统通常是一个简单的重试直到确认系统,比 TCP 更简单,但有些协议远远超出了 TCP 所能提供的范围.

The reliable packet system is usually a simple retry-until-acknowledged system simpler than TCP but there are protocols which go way beyond what TCP can offer.

你的情况听起来很简单.您可能能够自己制定最干净的解决方案 - 只需让每个客户端发回我听到了"响应并让服务器继续尝试直到它得到它(或放弃).

Your situation sounds very simple. You'll probably be able to make the cleanest solution yourself - just make every client send back an "I heard you" response and have the server keep trying until it gets it (or gives up).

如果您想要更多内容,大多数自定义协议库都使用 C++,所以我不确定它们对您有多大用处.但是,我在这里的知识是几年前的-也许现在已经移植了一些协议.嗯... RakNet 和 enet 是我想到的两个 C/C++ 库.

If you want something more, most custom protocol libraries are in C++, so I am not sure how much use they'll be to you. However, my knowledge here is a few years old - perhaps some protocols have been ported over by now. Hmm... RakNet and enet are two C/C++ libraries that come to mind.

这篇关于像UDP一样广播,具有TCP的可靠性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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