简体   繁体   中英

Java RMI - specifying the port to use for communication

As far as I know, RMI uses random ports for communicating between object's stub and remote object. To make things work through firewall, we need to know which ports to open. Now, isn't it enough to create a stub using UnicastRemoteObject.exportObject(Remote obj, int port) ? According to documentation, it "Exports the remote object to make it available to receive incoming calls, using the particular supplied port." Does it create a stub that, for any subsequent invocation of remote method, uses this particular port for communication with remote object? If not, then what this port argument does?

Does it create a stub that, for any subsequent invocation of remote method, uses this particular port for communication with remote object?

Yes.

If not, then what this port argument does?

It does that. It also determines what port the remote object is listening on, of course.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM