RMI: take ip/hostname what client was using and give it back as aremote objects hostname

Discussion in 'Java' started by AWieminer, Jul 12, 2005.

  1. AWieminer

    AWieminer Guest

    RMI: take ip/hostname what client was using and give it back as a remote
    objects hostname. Long question but here is what I try to ask.

    Currently I use the following code to start RMIRegistry inside my
    application and bind Remote objects. I can bind several objects to the
    same port. Actually, I run a rmi registry lookup and remote object
    "handles" in a same fixed port. Its more NAT-firewall friendly.

    When clients lookup a remote object handle from the registry, they
    receive a hostname where given service is running. It is a server that
    tells them to use that hostname. This is a small problem in a
    NAT-firewall world.

    I must use "-Djava.rmi.server.hostname=myPublicHostName.com" commandline
    parameter to override internal hostname seen by the server machine. It
    would give internal DMZ ip address if not overriden this way.

    Best method would use the same hostname what client was using the first
    place when connected to RMI registry to look for remote handles. It is
    after all an address it can use when connecting to our server.

    Is it possible to take that ip/hostname and give it back along with the
    remoteobject's hostname?

    - - - -
    Registry reg;

    public void createReg(int port) throws Exception {
    try {
    reg = LocateRegistry.createRegistry(port); // registry port number
    } catch (Exception ex) {
    // probably was already running so take existing registry instance.
    reg = LocateRegistry.getRegistry(port);
    }
    }

    public void bindService(String id, int port) thows Exception {
    Remote obj = createMyRemoteImplementationXX();
    UnicastRemoteObject.exportObject(obj, port);
    reg.rebind(id, obj);
    }
    - - - -
    AWieminer, Jul 12, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Murko
    Replies:
    0
    Views:
    841
    David Murko
    Dec 2, 2004
  2. Replies:
    2
    Views:
    2,135
    Chris Uppal
    Mar 17, 2006
  3. grocery_stocker
    Replies:
    10
    Views:
    603
    Keith Thompson
    May 25, 2005
  4. Barbiturico76

    Generate HTML and give it back to client

    Barbiturico76, Jul 28, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    288
    Barbiturico76
    Jul 29, 2008
  5. Paw
    Replies:
    8
    Views:
    384
Loading...

Share This Page