简体   繁体   中英

chat application, sockets vs RMI

I want to build a chat application and am confused about deciding whether to use sockets or RMI to build the application. I have heard that RMI is difficult to configure and deploy over the Internet, since that is my intention I was wondering what would be more appropriate to go with, sockets or RMI. Also is it easier to solve issues because of NAT in sockets or RMI ?

What if I want to add voice support at some later point, does it help deciding which way to go ?

1. For applications like Chat Messenger , my bet will be on Sockets.

2. RMI will be an over kill here .

3. Moreover NAT issue is not about Socket or RMI , its about Static IPs.

4. If you want to deploy a Chat Server over the net, then first you must have a Static IP, you need to have to ask your ISP to provide you with one of them at extra cost, or there are sites over internet, that makes your dynamic ips as static.

5. But if your server is locally located in a LAN environment, then i think you won't have a problem in doing it.

Both are reasonable choices that could be used to build a chat server/client. A socket can be set up to take incoming connections and start a new thread for each "chatter" alternatively RMI can be used to create a distributed object on which the client can call methods.

RMI is basically a layer over sockets often used in distributed computing where some transparency is needed and remote methods need to be called. It also allows for stateless connections to the server.

If you choose to implement the server in RMI just be warned that thread safety may be an issue.

For a local server it is probably easier to use pure sockets.

For more details on RMI: http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136424.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM