简体   繁体   English

如何仅在一种协议上运行 Kryonet 服务器?

[英]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 SACKNACK数据包允许更快的重传请求,并且显式拥塞通知增强功能使对等方以接近网络可以处理的最大速度进行通信变得更加容易。 (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.

相关问题 在kryonet中,如何在不停止程序的情况下与服务器断开连接? - In kryonet, how do I disconnect from a server without stopping my program? 如何通过KryoNet发送用户信息? - How do I send user information over KryoNet? Selenium Java-如何仅运行一项测试? - Selenium Java - how do I run only one test? KryoNet-如何使用布尔值xx = new clientprocess()启动客户端; 获得返回值? - KryoNet - How do I start client with Boolean xx = new clientprocess(); to get a return value? 我在Java服务器中拥有五个线程,如何使它们同时运行一个任务? - I hava five threads in java server, how should I do to make them run one task concurrently? 如果它部署在N个实例上,如何仅在一个实例上运行夜间作业? - How do I run a nightly job only on one instance if it is deployed on N instances? 我如何只运行一次此活动? - How do i run this activity only once? 我可以在Java服务器上运行Meteor DDP Server协议吗? - Can I run the Meteor DDP Server protocol on a Java server? Kryonet - 如何在课堂上注册课程? - Kryonet — How can I register classes within my class? 如何保护Kryonet(SSLSocketChannel) - How to secure Kryonet (SSLSocketChannel)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM