Java 中的网络通信选项(客户端/服务器)
有 RMI(我认为它相对脆弱)、直接 Socket 连接(级别相当低)和字符串(虽然它看起来很可靠),但它似乎是隐喻的 PHP。
对于基于互联网的客户端/服务器通信,我有哪些不太基本的选项?有什么优点/缺点?我应该考虑哪些问题?第三方库建议很好,只要它们保持平台独立(即没有限制性的本机代码)。
寻找选项,而不是确定的答案,所以我将自己的要求细节留空。
There is RMI, which I understand to be relatively fragile, direct Socket connections, which is rather low level, and Strings, which while about as solid as it gets seems to be the metaphorical PHP.
What less basic options do I have for internet based Client/Server communication ? What are the advantages/disadvantages ? What are some concerns I should take into consideration ? Third party library suggestions are fine, as long as they stay platform independent (i.e. no restrictive native code).
Looking for options, not a definite answer, so I'm leaving the details of my own requirements blank.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您指定“基于互联网”时,对于基于 HTTP 的 RESTful 方法(我强调了您应该考虑的一些问题):
优点:
缺点:
As you specified "internet based", there's a lot to be said for an HTTP-based, RESTful approach (I've highlighted some concerns you should consider):
Pros:
Cons:
“相对脆弱”是什么意思? RMI 的问题在于它是一个狭窄基础上的大型上层建筑,特别是它对 DNS 和对象序列化有很大的依赖。离芯片越近,程序就越不“脆弱”,但需要编写的代码也就越多。这是一个权衡。我不是 RMI 的单眼支持者,尽管我写过一本关于 RMI 的书,但“脆弱”这个词太重了。它做了它该做的事,而且做得相当好。如果您需要大规模的可扩展性,RMI/IIOP 在许多方面都做得更好。如果您对世界的看法是最多一次远程方法调用而没有太多安全性,那么 RMI/JRMP 将为您提供它。你离这个模型越远,应用起来就越困难。
What does 'relatively fragile' mean? The issues with RMI have to do with it being a large superstructure on a narrow foundation, and specifically that it has a large reliance on DNS and Object Serialization. The closer you are to the silicon, the less 'fragile' any program becomes, but the more code you have to write. It's a tradeoff. I'm not a one-eyed RMI supporter, despite having written a book about it, but 'fragility' is too strong a word. It does what it does, and it does that reasonably well. RMI/IIOP does it even better in many respects if you need large-scale scalability. If your view of the world is an at-most-once remote method call without too much security, RMI/JRMP will give it to you. The further you get from that model the harder it becomes to apply.