Hi John,
I just wondering, about the real projects.
in which situation I must use the socket programming ?
in which situation I must use the RMI ?
It is difficult to say. Personally, if you need specific *treatment* on the data sending, say for performance, you will use socket. Because you can customize the data you send, including the data format. Just the receiver knows how to decode the data (object) is fine.
For RMI, you dont need to handle anything.
Java provides APIs for serializing and deserializing the objects. However, you have no control on how the data is
exchange.
Thus, the method you choose depends on what you wanna.
at home, I always use swing, jdbc and other libraries.....
if we are using JDBC to connect to the database server (client and server model) so, in which time I use sockets, RMI ?
IMO, you wont connect to the DB from client using JDBC. The responsibility of connecting to the DB should be resided on the server. Client makes a call, say retrive XXX data. The server receives such a request, and connect to the DB, retrieve XXX data on behalf of the client, and return the result. In such sense, both RMI and sockets work well.
The choice then falls on what is the return object you wanna. Serialized object or not. If not, you may need sockets. If yes, you can simply use RMI.
how the real projects use these technologies ?
I am trying to use these technologies when developing at home, but I don't know where ??
What do you wanna know? For myself, I worked with RMI in my
SCJD assignment. You need to develop an interface to capture client request, and connect to the DB using either RMI or socket. I think you can simply write a Java application that connects to a daemon server using RMI or socket. Then you can try it at home.
You even dont need to have 2 machines. RMI can be connected by local (simulate the remote situation) by using the loopback address.
Hope this help.
Nick
SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)