[英]Game server TCP networking sockets - fairness
I'm writing a game server for a turn-based game. 我正在为回合制游戏编写游戏服务器。 One criteria is that the game needs to be as fair for all players as possible. 一个标准是游戏必须对所有玩家尽可能公平。
So far it works like this: 到目前为止,它的工作方式如下:
My concern for fairness raises the following questions: 我对公平的关注提出了以下问题:
Thanks in advance for your feedback and tips. 在此先感谢您的反馈和提示。
Does it matter in which order I send messages to the clients? 我以什么顺序向客户发送消息有关系吗?
Yes, by fractions of milliseconds. 是的,以毫秒为单位。 If the network interface is available for sending the OS will immediately start sending. 如果网络接口可用于发送,则操作系统将立即开始发送。 Why would it wait? 为什么要等待?
Perhaps I should be sending to the highest-latency clients first? 也许我应该先发送给延迟最高的客户?
I think you should be sending in random order. 我认为您应该以随机顺序发送。 Shuffle the list prior to sending. 发送前先随机播放列表。 This makes it fair. 这很公平。 I think your question is valid and this should be addressed. 我认为您的问题是有效的,应该解决。
Currently I'm writing them as one large chunk. 目前,我将它们写成一大块。 [...] [...]
First, realize that TCP is stream-based and that there are no packets/messages at the protocol level. 首先,认识到TCP是基于流的,并且在协议级别上没有包/消息。 On a physical level data is indeed packetized. 在物理级别上,数据确实是打包的。
It is not necessary to manually split off packets because clients will read data as it arrives anyway. 无需手动拆分数据包,因为无论如何,客户端都会读取数据。 If a client issues a read, that read will complete immediately once the first packet has arrived. 如果客户端发出读取,则第一个数据包到达后,该读取将立即完成。 There is no artificial waiting in the OS. 操作系统中没有人为的等待。
Are there any linux/networking configurations that would bear impact here? 是否有任何Linux /网络配置会在这里产生影响?
I don't know. 我不知道。 Be sure to disable nagling. 确保禁用打na。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.