user107986
user107986

Reputation: 1541

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?

Upvotes: 0

Views: 398

Answers (1)

user207421
user207421

Reputation: 310913

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.

Upvotes: 2

Related Questions