Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How does the port determined

 
Kumar Kausikasa
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I understand how rmi works. The client requests an object by name to the RMI registry, once the client has the stub it make calls to the remotes method.I have gone through the RMI specification doc and underneath it actually opens a socket, but who determines on which port it shoud talk?..Is this done at compile time and run time?
Can someone explain in detail.
Thanks for your time
Thanks
Praveen.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Praveen,
Well I don't pretend to be an expert on RMI but I will tell you what little I do know about RMI and ports. The RMI registry is bound to port 1099 by default but can be bound to virtually any available port on the system. Now when a client requests a connection to a service that is bound to the RMI registry then the RMI server usually opens an anonymous port (which is whatever available port the system gives it) for that client to communicate with the remote service. It's like you creating a ServerSocket like:

This is why RMI has such a hard time with firewalls. Nobody knows for sure what ports are going to be needed. When this problem arises though custom SocketFactories can be implemented to use selected ports.
Hope this helps,
Michael Morris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic