473,756 Members | 3,111 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 15721
"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
3723
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
43158
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
1598
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
2632
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
2347
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
4770
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
2539
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
1415
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
9325
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9716
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8569
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6410
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
4996
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3676
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
3185
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2542
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.