Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI client connecting to multiple IP/ports

 
K. Tsang
Bartender
Posts: 3521
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I want to ask for the SCJD assignment, multiple clients are expected. So if I start the RMI server on IP 192.168.0.2 on port 1234 for example. First client choose this server and port 1234 - connects fine. Second client choose sam server but port 1235. When this 2nd client runs client app, it gets java.rmi.ConnectException because the currently started server on ip 192.168.0.2 is with port 1234 and not 1235. What do people do in this case? Also what about if client choose a new IP which server isn't running, java.rmi.ConnectException will prompt.

Ideally I should send a "remote command" to that IP and say start the server. But how to send remote command? I can't call the server code on the client computer because the IP is different.

I see some people use "rmi://server_ip:port/filename", but when is this used and where?
 
Alecsandru Cocarla
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All clients should connect on the same port.
If the port is not configured ok for a client, just show to the user that there's no server listening on that port (maybe tell him to try again, or to check if there's any server running on the machine he's trying to connect to).
You don't have to start anything if the client is not wise enough to enter the correct numbers.
 
Kevin Florish
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Alec says provivide a clean exit and stop the application.

Make the user aware from a dialog box or something what the general error is.

There is at most 1 server running and multiple clients, I think a general error response with information is enough for this project.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic