473,408 Members | 2,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

RMI Registry and UnicastRemoteObjects - sharing ports

Hello group,

I am trying to cut down the number of ports that must be opened in a
firewall to let the client talk to the protected server. The server runs its
own registry process by calling LocateRegistry.createRegistry(port), and the
same port is used when UnicastRemoteObjects are exported. This way, I can
tell the firewall admin to open only one hole in the firewall, instead of
two.

It all works, until I attempt to use a custom socket factory for the
registry (the factory explicitly sets the IP address to which the registry
binds - important for the multi-homed servers). If I set the socket factory
to the registry only:

LocateRegistry.createRegistry(port, null, mySocketFactory)

and leave the exported objects to their default factory settings, I get a
"port already in use" exception. If I set the same instance of the socket
factory to the UnicastRemoteObjects, this is what happens:

1. The first UnicastRemoteObjects exports normally and responds to the
remote calls.
2. Any other UnicastRemoteObject to be exported on the same port with the
same instance of the socket factory throws the same old "port already in
use" exception.

What am I missing in my version of the socket factory that the default
implementation has and what lets it bind multiple objects to the same port
without blowing up?

Here is the source code for the socket factory:

public class RegistrySocketFactory extends RMISocketFactory implements
Serializable
{
private InetAddress ipInterface = null;
private static RegistrySocketFactory instance = null; // turn this
class into a singleton
public RegistrySocketFactory(InetAddress ipInterface)
{
this.ipInterface = ipInterface;
instance = this;
}
public static RegistrySocketFactory getInstance()
{
return (instance);
}
public ServerSocket createServerSocket(int port)
{
ServerSocket serverSocket = null;
try
{
serverSocket = new ServerSocket(port, 50, ipInterface);
}
catch (Exception e)
{
System.out.println(e);
}
return (serverSocket);
}
public Socket createSocket(String ipInterface, int port) throws
IOException
{
Socket socket= new Socket(ipInterface, port);
return socket;
}
}

And this is the snippet of the context in which it is used:

RegistrySocketFactory socketFactory = new RegistrySocketFactory(address);
LocateRegistry.createRegistry(6541, null, socketFactory);
proxy = new Proxy(6541); // this works
proxyHook = new ProxyHook(this); // this throws "port in use"
exception

public Proxy(int port) throws RemoteException
{
super(6541, null, RegistrySocketFactory.getInstance());
}

public ProxyHook(Proxy controller) throws RemoteException
{
super(6541, null, RegistrySocketFactory.getInstance());
}
Jul 17 '05 #1
0 2162

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: DavidE | last post by:
Hi, Recently, when I try to open files in web projects with visual interdev 6 I get this error message: Server error: Error 2 opening registry key Software/microsoft/shared tools/web server...
1
by: rdavis7408 | last post by:
I have a database that has a form that opens a report using date parameters. I have been using it for six months and last week I began to get the following Error Message: "File sharing lock...
3
by: andyI | last post by:
Where do I find information on how to address and pass data to and from the serial ports and USB ports in VB. VB6 supports the serial ports easily but I see no reference to using the USB ports....
3
by: Steve Montgomery | last post by:
Does anyone have a sample block of code they can share for checking a DWORD value on a remote network machine's registry? For example, to validate a patch deployment. MSDN has a great sample for...
12
by: Li Pang | last post by:
Hi, I'd like to know how to remove registry keys which contain a value of 'appkeyA' or 'appkeyB' or 'appkeyC' ...? thanks in advance
1
by: henrycortezwu | last post by:
Hi All, I'm trying to connect to a virtual port (COM19, OUTGOING, "Bluetooth Serial Port") using VS2005 System.IO.Ports. When I ran the ff code below here's what happens. 1) VS2005 Compiles w/o...
2
by: joaquimfpinto | last post by:
Dear All, I made an app in c# that uses several serial ports. For the serial ports I use a pnp Sunix board, some with 8 serial ports other with 4 or even 2 serial ports. Whenever I use the...
1
by: mdfidahussain | last post by:
Hi Friends, Anyone help me out in getting Ports' status information from the Registry Key? if there is no possibility of getting this info from Registry entry, is there any other way from whic I...
10
by: sklett | last post by:
I'm trying to send some printer commands (ZPLII) to an attached USB printer using the SerialPort component. I didn't get very far at all. In fact I haven't gotten anywhere. The first problem I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.