Is there a method to know the port number of both the client and server during RMI?
When a result is returned during RMI to the client, next time the client requests the result, will the conversation between client and server be at the same port as the previous, when the server has been running since the first result was returned or a new port is created?
for example :
// call to a remote method add
addServerIntf.add(d1,d2)
// after this call i get the added result
// again call the add method by again starting the client
addServerIntf.add(d1,d2)
// I get the result back as usual
In the 2 different calls does the port number of client and server remain the same ?
My client program exits after entering a command like java AddClient localhost 100 200 The method on the server returns 300 and the client exits. Next time i start my client again with java AddClient localhost 19 100. Now will request be sent from the same port as sent from before and will the server receive the request on the same port ? Or the situation is different from what i just wrote ?
Is there a method to know the port number of both the client and server?
No. You can't know the client port number in advance, as it is allocated dynamically on connection, and the server IP:port is embedded in the stub where you can't get at it. Why would you need to know? The information can't do you much good: you can't use it.
When a result is returned during RMI to the client, next time the client requests the result, will the conversation between client and server be at the same port as the previous, when the server has been running since the first result was returned or a new port is created?
Either:
It is impossible to tell which. The server port remains fixed.
In the 2 different calls does the port number of client and server remain the same ?
See above.
My client program exits after entering a command like
java AddClient localhost 100 200
. The method on the server returns 300 and the client exits. Next time i start my client again withjava AddClient localhost 19 100
. Now will request be sent from the same port as sent from before
Probably not.
and will the server receive the request on the same port?
Impossible to say without seeing your server code. If you exported it on a constant port, it is exported on a constant port. If not, not. Tautology really.
Or the situation is different from what i just wrote?
I don't understand the question.