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
Gordon Beaton - 18 Jun 2007 15:05 GMT
> In other words I would like to see:
>
[quoted text clipped - 3 lines]
> 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
--
Tom Hawtin - 18 Jun 2007 15:08 GMT
> I have code that starts the RMI registry as follows:
>
[quoted text clipped - 5 lines]
> 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