aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RMI client connecting to multiple IP/ports Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "RMI client connecting to multiple IP/ports" Watch "RMI client connecting to multiple IP/ports" New topic
Author

RMI client connecting to multiple IP/ports

K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2615
    
    9

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?


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Alecsandru Cocarla
Ranch Hand

Joined: Feb 29, 2008
Posts: 158
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.


SCJP 1.4 100%
SCJD 99.5%
Kevin Florish
Ranch Hand

Joined: Jan 06, 2009
Posts: 176
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.


Java5 Tutorials | Java6 Tutorials | HTML/CSS Tutorials | JavaScript and jQuery Tutorials
 
 
subject: RMI client connecting to multiple IP/ports