• Post Reply Bookmark Topic Watch Topic
  • New Topic

convert ing socket to RMI question

 
Shay Gaghe
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i have client/server program that use socket connection ,to avoid deadlocks i use Thread. now i moved on RMI and i wonder if i need Thread process inside my classes like i used to do with the socket based program?
whats are the pluses and minuses of using RMI instead of socket connection?
do web server support RMI(the servers whose provides a domin for publish the program)?
thanks
Shay Gaghe
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sockets and RMI are two ways to attack essentially the same problem. The key difference is that RMI understands Java's form of object serialization (and the hurdles that must be cleared to solve a host of related issues). Here's more info on serialization to see what services are available.
Sockets factor out the detail in getting two processes to agree on connecting through their network layers. But that's pretty much it: IP and port addresses, connection-oriented or connectionless message style, and not much else gets decided. RMI does the dissembly/assembly of bits that make up object content for you.
You still have to think about synchronization of data between two processes, but now your problems are more focussed. With RMI, you can tell the client to rely on and draw data from the server side. Thus there's really only on authoritative copy of 'remote' data. With sockets you're passing copies and adding whatever mechanism you think is necessary to keep the two sides in sync.
To summarize: sockets are a data transport. The usual API for building them into a distributed programming model is called RPC (Remote Procedure Call). RMI is much like RPC, but it is a *whole* lot simpler. It's more powerful features are also a tad subtle; you may not seem them for what they are until you've played with it for a while.
Web server protocols (HTTP, HTTPS) aren't really intended for the kind of work RMI does, but Applet communication between client and server is about as close as you can get to RMI without doing it yourself.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!