[英]How do I run a Kryonet server, only on one protocol?
I'm currently planning to use the Java networking library, Kryonet, for my game.我目前正计划在我的游戏中使用 Java 网络库 Kryonet。 I'm going to use the UDP protocol, as it is faster than TCP.
我将使用 UDP 协议,因为它比 TCP 快。 I like the Kryonet API, its very clean code, however it appears to only allow running of servers, on both TCP and UDP, when I only want a server running on UDP.
我喜欢Kryonet API,它非常干净的代码,但它似乎只允许运行的服务器,对TCP和UDP,当我只希望在UDP上运行的服务器。
I don't think you should make the assumption that UDP is "faster" than TCP. 我不认为您应该假设UDP比TCP“更快”。 TCP SACK and NACK packets allow for faster retransmission requests than the older TCP sliding-window-only system, and the Explicit Congestion Notification enhancement makes it far easier for peers to communicate at a speed approaching the maximum the network can handle.
与旧的仅TCP滑动窗口系统相比,TCP SACK和NACK数据包允许更快的重传请求,并且显式拥塞通知增强功能使对等方以接近网络可以处理的最大速度进行通信变得更加容易。 (UDP would continue sending data oblivious to the congestion that leads to dropped packets.)
(UDP将继续发送数据,而不会导致导致丢包的拥塞。)
Test the bandwidth, latency, and packetloss between several intended peers and see which one performs better. 测试几个预期的对等设备之间的带宽,延迟和数据包丢失,看看哪个性能更好。 I'll bet it comes out nearly the same.
我敢打赌,结果差不多。
Kryonet in fact does support connections with only one protocol, but this one protocol must be TCP. Kryonet 实际上确实支持只有一种协议的连接,但这种协议必须是 TCP。 There are no UDP-only connections possible.
没有可能的仅 UDP 连接。 TCP is mandatory.
TCP 是强制性的。
Reason is, that kryonet uses TCP for all internal requests like server discovery, ping or the connection handshake.原因是,kryonet 将 TCP 用于所有内部请求,如服务器发现、ping 或连接握手。 Doing this in UDP would require logic to deal with dropped or wrongly-ordered packages which kryonet just doesn't have implemented yet.
在 UDP 中执行此操作需要逻辑来处理 kryonet 尚未实现的丢弃或错误排序的包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.