gpt4 book ai didi

java - 如何在Java中仅通过套接字通信来实现流量控制?

转载 作者:行者123 更新时间:2023-12-02 00:48:31 24 4
gpt4 key购买 nike

我目前正在使用套接字用 Java 编写一个简单的客户端/服务器。我希望服务器根据通过套接字从客户端接收的不同“命令”和/或序列化对象做出决定,反之亦然。

类似于:

[Receive Command 'DoSomething' From Client]
[Call Method 'DoSomething' on the Server]
[Send result/status to Client]
etc...

是否有像这样使用普通套接字通信(也许通过序列化)进行流量控制的约定?我应该在 Java 中使用 RMI 吗?

最佳答案

我会推荐 KryoNet 来做任何 RMI 类型的事情,而不需要 RMI 的开销和它带来的不灵 active 。

http://code.google.com/p/kryonet/

KryoNet makes the assumptions that it will only be used for client/server architectures and that KryoNet will be used on both sides of the network. Because KryoNet solves a specific problem, the KryoNet API can do so very elegantly.

The Apache MINA project is similar to KryoNet. MINA's API is lower level and a great deal more complicated. Even the simplest client/server will require a lot more code to be written. MINA also is not integrated with a robust serialization framework and doesn't intrinsically support RMI.

The Priobit project is a minimal layer over NIO. It provides TCP networking similar to KryoNet, but without the higher level features. Priobit requires all network communication to occur on a single thread.

The Java Game Networking project is a higher level library similar to KryoNet. JGN does not have as simple of an API.

关于java - 如何在Java中仅通过套接字通信来实现流量控制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4200759/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com