I have started tinkering with RMI in
java. It is very different from the network socket concept and seems to be much more powerful. But how do you invoke multithreading in the main method of a RMI server to server multiple clients? or does RMI automatically take care of this. Ok, what I mean by my question is: In normal client-server code using sockets, I would normally use a code like this in the main method of the server:
try {
while(true) {
// Blocks until a connection occurs;
Socket socket = s.accept();
try {
System.out.println("opening new Server thread");
new ServerThread(socket);
} catch(IOException e) {
// If it fails, close the socket,
// otherwise the
thread will close it
socket.close();
}
The ServerThread would do the work required of the server.
But in RMI, there is no such a thing as s.accept(). All one does is have a statement like Naming.rebind("test",t); and it waits for client connections on a separate thread. My question is does RMI automatically create new threads as every client connects to the server?