473,893 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RMI binding to SAME port but DIFFERENT IP address on SAME host

If I have a machine with 3 virtual IP addresses (192.168.1.[5-7]), how
can I start 3 instances of the same RMI application (each started with
different properties/configs), each listening on the port 1234, but each
instance binds to a different ip address.

that is to say:
instance #1 binds to 192.168.1.5/port 1234
instance #2 binds to 192.168.1.6/port 1234
instance #3 binds to 192.168.1.7/port 1234

I guess I am looking for something like:
Registry registry = LocateRegistry. createRegistry( <IPADDR>,<PORT> );

I tried
System.setPrope rty("java.rmi.s erver.hostname" ,"<IPADDR>") ;
but had no luck
current code looks something like this:

/******* server side *********/
System.getPrope rties().setProp erty("java.rmi. server.hostname ",serverip) ;
Registry registry = LocateRegistry. createRegistry( serverport);
registry.rebind ("RMITest", this);

//serverip is the IP to bind to... server port is port 1234

/******* client side **********/
Registry registry=Locate Registry.getReg istry(serverip, serverport);
RMITestInterfac e rmit=(RMITestIn terface)(regist ry.lookup("RMIT est"));
rmit.dosomethin gcool();
second instance (even though serverip is different) complains
java.rmi.server .ExportExceptio n: Port already in use:1234; nested
exception is: java.net.BindEx ception: Address already in use

These have to be seperate instances of the application for each
customer... I know that it is possible to run them on different ports,
but this is really not acceptable in a large clustered environment. this
would become a complete nightmare very quickly.
what am I missing?!?! I have googled high and low, and looked through
all my java books, but see no mention of such a scenario! anyone?

TIA!

-alex
Jul 17 '05 #1
21 15750
"Alexander N. Spitzer" <al**@spitzer.N OSPAMPLEASE.org > wrote in message
news:mN******** ********@nwrdny 03.gnilink.net. ..
[snipped]
I guess I am looking for something like:
Registry registry = LocateRegistry. createRegistry( <IPADDR>,<PORT> );


There is no method in LocateRegistry with this signature. You can create a
Registry object bound to a specific IP address using this form of the
method:

public static Registry createRegistry( int port, RMIClientSocket Factory csf,
RMIServerSocket Factory ssf) throws RemoteException

You will have to provide a class that implements the RMIServerSocket Factory
interface (the RMIClientSocket Factory parm can be null); this class will
create a ServerSocket that you will have to bind to the desired IP address.
Here is an example:

import java.rmi.server .*;
import java.io.*;
import java.net.*;
public class AnchorSocketFac tory extends RMISocketFactor y implements
Serializable
{
private InetAddress ipInterface = null;
public AnchorSocketFac tory() {}
public AnchorSocketFac tory(InetAddres s ipInterface)
{
this.ipInterfac e = ipInterface;
}
public ServerSocket createServerSoc ket(int port)
{
ServerSocket serverSocket = null;
try
{
serverSocket = new ServerSocket(po rt, 50, ipInterface);
}
catch (Exception e)
{
System.out.prin tln(e);
}
return (serverSocket);
}
public Socket createSocket(St ring dummy, int port) throws IOException
{
return (new Socket(ipInterf ace, port));
}
public boolean equals(Object that)
{
return (that != null && that.getClass() == this.getClass() );
}
}

In your code do this:

AnchorSocketFac tory sf = new AnchorSocketFac tory(<your InetAddress>);
LocateRegistry. createRegistry( port, null, sf);

HTH

Alex Molochnikov
Gestalt Corporation
www.gestalt.com
Jul 17 '05 #2
Sam
"Alexander N. Spitzer" <al**@spitzer.N OSPAMPLEASE.org > wrote in message news:<mN******* *********@nwrdn y03.gnilink.net >...
If I have a machine with 3 virtual IP addresses (192.168.1.[5-7]), how
can I start 3 instances of the same RMI application (each started with
different properties/configs), each listening on the port 1234, but each
instance binds to a different ip address.

that is to say:
instance #1 binds to 192.168.1.5/port 1234
instance #2 binds to 192.168.1.6/port 1234
instance #3 binds to 192.168.1.7/port 1234

I guess I am looking for something like:
Registry registry = LocateRegistry. createRegistry( <IPADDR>,<PORT> );

I tried
System.setPrope rty("java.rmi.s erver.hostname" ,"<IPADDR>") ;
but had no luck
current code looks something like this:

/******* server side *********/
System.getPrope rties().setProp erty("java.rmi. server.hostname ",serverip) ;
Registry registry = LocateRegistry. createRegistry( serverport);
registry.rebind ("RMITest", this);

//serverip is the IP to bind to... server port is port 1234

/******* client side **********/
Registry registry=Locate Registry.getReg istry(serverip, serverport);
RMITestInterfac e rmit=(RMITestIn terface)(regist ry.lookup("RMIT est"));
rmit.dosomethin gcool();
second instance (even though serverip is different) complains
java.rmi.server .ExportExceptio n: Port already in use:1234; nested
exception is: java.net.BindEx ception: Address already in use

These have to be seperate instances of the application for each
customer... I know that it is possible to run them on different ports,
but this is really not acceptable in a large clustered environment. this
would become a complete nightmare very quickly.
what am I missing?!?! I have googled high and low, and looked through
all my java books, but see no mention of such a scenario! anyone?

TIA!

-alex

Alex,

I doubt an end host keeps multiple ports for each active ip address.
Data from a nic card is passed up the protocol stack, and the source
ip address has been discarded by the time it reaches the port.

You might try a single RMI server listening on a single port, passing
data to a given instance of a jvm based on customer id.

Sam90
Jul 17 '05 #3
> Alex,

I doubt an end host keeps multiple ports for each active ip address.
Data from a nic card is passed up the protocol stack, and the source
ip address has been discarded by the time it reaches the port.

You might try a single RMI server listening on a single port, passing
data to a given instance of a jvm based on customer id.

Sam90


Sam, in an ASP environment, it is a requirement to have seperate
instances for each client.

Alex Molochnikov gave me the answer I was looking for, which was:

There is no method in LocateRegistry with this signature. You can create
a Registry object bound to a specific IP address using this form of the
method:

public static Registry createRegistry( int port, RMIClientSocket Factory
csf,RMIServerSo cketFactory ssf) throws RemoteException

Thanks Alex M. et al.!
Jul 17 '05 #4
Sam wrote:

I doubt an end host keeps multiple ports for each active ip address.
Data from a nic card is passed up the protocol stack, and the source
ip address has been discarded by the time it reaches the port.


Sam, none of this guesswork is true.

Jul 17 '05 #5
Sam
"Alexander N. Spitzer" <al**@spitzer.N OSPAMPLEASE.org > wrote in message news:<41******* *******@spitzer .NOSPAMPLEASE.o rg>...
Alex,

I doubt an end host keeps multiple ports for each active ip address.
Data from a nic card is passed up the protocol stack, and the source
ip address has been discarded by the time it reaches the port.

You might try a single RMI server listening on a single port, passing
data to a given instance of a jvm based on customer id.

Sam90
Sam, in an ASP environment, it is a requirement to have seperate
instances for each client.
That actually is what I was proposing - but that's a moot point, since
you got Alex's correct answer.

Alex Molochnikov gave me the answer I was looking for, which was:
There is no method in LocateRegistry with this signature. You can create
a Registry object bound to a specific IP address using this form of the
method:

public static Registry createRegistry( int port, RMIClientSocket Factory
csf,RMIServerSo cketFactory ssf) throws RemoteException
My bad - I did some speculation which I didn't check, and now see what
happened. Alex's answer didn't make to Google by the time I made my
post

Thanks Alex M. et al.!


Agreed.

Regards,
Sam90
Jul 17 '05 #6
Sam
Esmond Pitt <es*********@no t.bigpond.com> wrote in message news:<Dt******* ************@ne ws-server.bigpond. net.au>...
Sam wrote:

I doubt an end host keeps multiple ports for each active ip address.
Data from a nic card is passed up the protocol stack, and the source
ip address has been discarded by the time it reaches the port.


Sam, none of this guesswork is true.


It isn't? How so?

Regards,
Sam90
Jul 17 '05 #7
Sam wrote:
I doubt an end host keeps multiple ports for each active ip address.
Data from a nic card is passed up the protocol stack, and the source
ip address has been discarded by the time it reaches the port.


Sam, none of this guesswork is true.

It isn't? How so?


Because what the OP described is perfectly possible, despite your doubts
and speculations. See ServerSocket(po rt,backlog,bind Address). If you
don't know the answer please don't guess, it only confuses others.

Jul 17 '05 #8
Sam
Esmond Pitt <es*********@no t.bigpond.com> wrote in message news:<8A******* ************@ne ws-server.bigpond. net.au>...
Sam wrote:
I doubt an end host keeps multiple ports for each active ip address.
Data from a nic card is passed up the protocol stack, and the source
ip address has been discarded by the time it reaches the port.

Sam, none of this guesswork is true.

It isn't? How so?


Because what the OP described is perfectly possible, despite your doubts
and speculations.


I agree my speculation was incorrect, and I admit it and I'm not happy
about it. However, I did qualify it, that is I didn't say "this is the
gospel truth" or anything like that. I said "I doubt it", which
liberally translated means, "I'm shooting from the hip, beware".
Besides, nothing I said was actually false. I just want to clarify
that. Specifically, an end host doesn't track mutliple ports per ip -
does it? When data is passed up the protocol stack, the IP address is
discarded by the time it reaches
See ServerSocket(po rt,backlog,bind Address).
I have, and I'm pretty sure I figured out where I went wrong.
If you
don't know the answer please don't guess, it only confuses others.


I did get sloppy, and I admit it. Oh well, no harm done, luckily
someone came along with the correct answer, actually even before I
posted my poor one. I'll be more careful next time.

Regards,
Sam90
Jul 17 '05 #9
Sam

I don't really know what you mean by 'tracks multiple ports per IP',
which TCP certainly does otherwise nothing would work at all. Maybe you
mean 'multiple IP addresses per port'? in which case the answer is
certainly 'yes' as well, hence the ServerSocket constructor I referred
you to. The local IP address by which incoming data came in is not
reliable due to the 'weak end system model' described in the RFC, maybe
this is what you are referring to, but the IP address to which the
reading socket is bound is always available via Socket.getLocal Address().

EJP

Jul 17 '05 #10

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

Similar topics

2
3733
by: Aleksander Wodynski | last post by:
I have server, daemon and client (daemon and client on the same machine). When client starts it send query to the server, server send query to the deamon (daemon check if the client exist), daemon send a response to the server, server send a response to the client. First I had following numbers of udp ports: S_PORT 2613 /* Server Port number */ S1_PORT 2614 /* Server Port for Daemon response */ C_PORT 2620 /*...
9
43199
by: mBird | last post by:
I wrote a service that listens for broadcast messages from my firewall (UDP snmp trap messages) and parses and puts the data in an database. I'd also like to write an app that is a simple form that can listen in when it runs (so I can see messages in a form as they occur.) So I need the ability to listen to a UDP port with two apps at the same time (the service and my app). But when I do that I get an error:...
0
1603
by: AC [MVP MCMS] | last post by:
I have a full blown VS.NET 2003 solution with a handful of library assemblies, two web projects, and a few web service projects. The entire solution is in VSS. Recently our build server went haywire and the best solution was to blow away everything on the build server related to this solution (both filebase and virtual directories hanging off the default website). I recreated the shell of our solution's web projects...
1
2638
by: Bruce | last post by:
Hi, there, I meet a problem about comboBox binding. -------------------- Database: Northwind Tables: 1) Products 2) Categories I create a form (named "form1") to edit the record from Products table.
0
2352
by: Steven Bolard | last post by:
Hello, I am trying to port my .net 1.1 application to 2.0. I am using vs2005. I am trying to get my webservices to run and although i can compile them and and get wsdl and service descriptions through internet explorer when hitting the ..asmx url, i cannot generate a proxy class to use in my winforms assembly. When i try to generate a proxy, i get no error message but nor do i get a reference.vb so there is no type info. If i then try...
5
4778
by: zxo102 | last post by:
Hi, I am doing a small project using socket server and thread in python. This is first time for me to use socket and thread things. Here is my case. I have 20 socket clients. Each client send a set of sensor data per second to a socket server. The socket server will do two things: 1. write data into a file via bsddb; 2. forward the data to a GUI written in wxpython. I am thinking the code should work as follow (not sure it is feasible)...
2
2549
by: Goran Djuranovic | last post by:
Hi All, Is it possible to have mulitple TcpListeners on listening on the same IP address and different port? Something like: Dim t1 As New TcpListener("192.168.25.25", 9000) Dim t2 As New TcpListener("192.168.25.25", 9231) t1.Start() t2.Start() TIA
1
1420
by: hitechabdul | last post by:
Hi... friends I m facing a problem in Sockets. I m continuosly opening a socket to record some data, and again I am closing that port. Again I m oipening same port to play data which wasa previously recorded. Again I m opening to re record data on the same port. This process is continuosly in a thread. It is successfully working for 2 days continuosly.. after 2 days it is not opening that same port to bind. I have use setSockOpt to reuse...
2
2237
by: djsam931 | last post by:
hi, im creating a program that allows users to chat using udp sockets.. as a general description, what i did was fork a child process that sends a udp datagram via an ephemeral port while the parent listens on some specific port.. to test the program, i am using two different terminals on the same machine.. when i run the program on one terminal, i set the ip address to 127.0.0.2.. then, i run the same program in another terminal with...
0
9830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11243
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10927
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
8021
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7173
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6066
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4684
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4280
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3289
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.