RMI host binding question

G

G

Greetings,

I have code that starts the RMI registry as follows:

LocateRegistry.createRegistry(5000);

This works fine, however the registry listens on all interfaces at the
port 5000. I would like rmi registry to listen only on localhost
interface, in similar fashion to the way you can make MySQL and
Postfix listen only to localhost. For example a netstat -ta would
reveal:

Proto Recv-Q Send-Q Local Address Foreign Address
State
tcp 0 0 localhost:mysql *:*
LISTEN
tcp 0 0 *:www *:*
LISTEN
tcp 0 0 localhost:smtp *:*
LISTEN
tcp 0 0 *:5000 *:*
LISTEN
tcp6 0 0 *:ssh *:*
LISTEN

In other words I would like to see:

tcp 0 0 localhost:5000
*:* LISTEN

Does anyone know if rmi registry supports interface binding like this?
From what I can tell, it does not.

Cheers,
Greg
 
G

Gordon Beaton

In other words I would like to see:

tcp 0 0 localhost:5000
*:* LISTEN

Does anyone know if rmi registry supports interface binding like this?
From what I can tell, it does not.

From what I can tell you can use the other createRegistry() method,
and specify an RMIServerSocketFactory to create the actual
ServerSocket that's to be used. So you should be able to create one
that binds to localhost:port.

Note: I haven't actually tried this.

/gordon

--
 
T

Tom Hawtin

G said:
I have code that starts the RMI registry as follows:

LocateRegistry.createRegistry(5000);

This works fine, however the registry listens on all interfaces at the
port 5000. I would like rmi registry to listen only on localhost
interface, in similar fashion to the way you can make MySQL and
Postfix listen only to localhost. For example a netstat -ta would
reveal:

The other LocateRegistry.createRegistry is;

public static Registry createRegistry(
int port,
RMIClientSocketFactory csf,
RMIServerSocketFactory ssf
)

So implement an RMIServerSocketFactory that creates server sockets bound
to the localhost address.

Tom Hawtin
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,084
Latest member
HansGeorgi

Latest Threads

Top