This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Random Port Numbers ?

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the master assignment, the client connects to the server through rmi.
The server runs on a particular port & the client gets the registry for that port & connects to it.

So I would like to get an advise from you guys that shall I randomly generate 4-digit port numbers which the server will use to create its rmiregistry ?
Like say if I use a fixed port for the server & that port is somehow blocked on the server machine then the ppl will have a hardtime fixing it, rather I'm generating a port no. which will get generated iff that port no. is not under use.
 
Ranch Hand
Posts: 221
Scala Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you do really need to think simple.

Typically Server Ports of a well known published service are kind of known and fixed.

If I remember correctly there is a well known default port for the RMI registry.

Why don't you just used that as the default?

You can give the freedom to the person starting the RMI server to specify an alternate port number.

Obviously you will need to handle the exception if the port number is already been used.

HTH,

Carlos.
 
Ray Dawson
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot.

Now I have kept the default RMI port (i.e 1099) as the default port no. it will listen to. Now if the port is already taken / blocked its exception will thrown & caught in which we will change the port no. to a free local port while notifying the user.
 
Carlos Morillo
Ranch Hand
Posts: 221
Scala Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think my approach was just to throw an Exception if the port it's already been used.

I had a textfield in the GUI to start my RMI server with the default port number giving the option to the user to change it.


HTH,


Carlos.
 
Ray Dawson
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carlos Morillo wrote:I had a textfield in the GUI to start my RMI server with the default port number giving the option to the user to change it.


Exactly what I did. And when the user entered a port number which was already in use, the server was not starting and an error was shown to the user.
 
Can't .... do .... plaid .... So I did this tiny ad instead:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic