File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RMI vs Sockets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "RMI vs Sockets" Watch "RMI vs Sockets" New topic
Author

RMI vs Sockets

Keith Jones
Ranch Hand

Joined: Oct 30, 2006
Posts: 105
Hi all,

I kind of have an idea how to implement a socket solution but not an RMI one. I am looking into doing it the RMI way since I have read that that is the easier option as you don't have to implement a threadsafe server as that is done for you (although I have read that the dissadvantage is that you can't use the thread's hashcode as the magic cookie). What I'd like to know is in the case of sockets the settings I would save to the .properties file on the client side are the ip address and port number of the server. For RMI what counterparts to this would I need to save?

Thanks


SCJP 1.4
Brian Kelly
Ranch Hand

Joined: Jan 04, 2007
Posts: 54
For server:
Server port
db file location

For client:
port number client uses
server IP address

For Standalon
db file location...

Your Data.java that implements the interface they give you should be thread safe...


SCJA, SCJP (1.4), SCJD
Keith Jones
Ranch Hand

Joined: Oct 30, 2006
Posts: 105
What do you mean by:

port number client uses


Is this the server's port the client wishes to connect to?
Mark Smyth
Ranch Hand

Joined: Feb 04, 2004
Posts: 288
Originally posted by Keith Jones:
What do you mean by:



Is this the server's port the client wishes to connect to?


Yep thats exactly what it is.
mark.


SCJP<br />SCJD
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
you don't have to implement a thread-safe server


Oh, yes you do!


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Mark Smyth
Ranch Hand

Joined: Feb 04, 2004
Posts: 288
Indeed. RMI does takes care of Multi-threading for you via an in built thread pool (ie you don't have to worry about to creating threads for each request). However it is still up to you to ensure that these RMI threads behave in a thread safe manner in your server code.

Mark.
[ January 25, 2007: Message edited by: Mark Smyth ]
Mandy Bowman
Ranch Hand

Joined: Jan 24, 2007
Posts: 32
Spank you all very much. I will try and implement the network layer now thanks for all the help guys. May God grant you all successful results in your exams.
Zhixiong Pan
Ranch Hand

Joined: Jan 25, 2006
Posts: 239
Before I entered this post, I want to find out the disadvantages and advantages of RMI and sockect respectively. But my requirement failed to meet.So could you talk on that differences in this post? In other word, why do you choose RMI instead of sockect, or maybe reversely.


SCJP 1.4 SCJD
Mark Smyth
Ranch Hand

Joined: Feb 04, 2004
Posts: 288
Too lazy today to go into it however these are some good discussions of RMI vs Sockets here:

http://www.coderanch.com/t/181307/java-developer-SCJD/certification/RMI-vs-Sockets

http://www.coderanch.com/t/184461/java-developer-SCJD/certification/Perogi-asks-RMI-vs-Sockets

http://www.coderanch.com/t/184090/java-developer-SCJD/certification/Anybody-interested-sockets-discussion

Mark
 
wood burning stoves
 
subject: RMI vs Sockets