且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java:套接字或RMI?

更新时间:2023-11-22 17:35:58

就个人而言,如果你只有一个方法调用,RMI似乎有些过分,所有的数据已经包裹在一个字符串。我想象一个简单的套接字服务器将足够满足您的需要。然而,RMI确实免费给你一些东西,比如多线程,分布式垃圾收集,对象编组等等。然而,如果你只有1个客户端,那么多线程可能没有用,因为你正在做自己的对象编组,然后这些好处可能不会给你带来什么。

personally, RMI seems like a bit of overkill if you've just got one method to call, and all your data is already wrapped in a string. i imagine a simple socket server would suffice very well for your needs. however, RMI does give you a bunch of stuff for free, like multithreading, distributed garbage collection, object marshalling, etc etc. however if you only have 1 client then multithreading might not be useful and since you're doing your own object marshalling then these benefits might not gain you anything.

这里有一个很好的页面rmi的能力: http://java.sun.com/javase/technologies/core/basic/rmi/whitepaper/index.jsp

there's a good page on rmi's capabilities here : http://java.sun.com/javase/technologies/core/basic/rmi/whitepaper/index.jsp