473,769 Members | 2,166 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
21 15724
Sam
Esmond Pitt <es*********@no t.bigpond.com> wrote in message news:<W6******* ************@ne ws-server.bigpond. net.au>...
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


Esmond,

My thinking was: whatever OS routine is responsible for delivering
payload data to a listening application over a specific port doesn't
need to know what IP address the data came over, it only needs to
deliver it to the correct port. The IP address doesn't even exist at
the transport layer. So to my mind the only the way the requirement
could be achieved was to somehow set up separate ports with the same
port number for each listening interface, which seemed unlikely.

However, what I failed to account for is that Java Sockets speak with
IP at some level, because for example they can specify the remote IP
in the Socket class. So, from there it's not much of a jump to realize
it probably has a way to understand the local IP address, as well.

I'm still unclear as to the mechanics of it, though. I'm pretty sure
that on Windows Jave uses JNI to interact with the WinSock API to
handle it's network functionality. But, my real question is, what
exactly is a "port" anyway, except a numeric label which has a
constraint that it can't be re-used within a single IP address? In the
end, it may be that it's simply a question of processes - the Winsock
API or corresponding OS module probably tracks some internal table
which matches a port to a specific interface, and as long the
combination of the two is different from all other entries in its
table, no problem. In the end, what I thought was "unlikely" is
probably what actually occurs - the OS tracks a separate port for each
interface, or at least has the capability of doing so. (DISCLAIMER:
the preceding is pure speculation...)

Regards,
Sam90
Jul 17 '05 #11
Sam

IP delivers data via sockets. That's what it does, it can't do anything
else. A socket is identified by its IP address, its port number, and its
protocol number. In the case of TCP, the socket is one end of a
connection whose other end is defined by *its* IP address and port
number. So, for the data to go anywhere at all IP has to know the local
address and port number *first*, i.e. it scans the table of sockets
somehow to find one with the target IP address/port/protocol no.
specified in the incoming IP packet. Then, the data is passed to that
socket, and the local IP address (& port) of any socket can be retrieved
via the Sockets API. This is nothing to do with Java, it all happens at
the IP layer. See W R Stevens 'TCP/IP Illustrated' for details. The only
time Java comes into it is by mapping the Sockets API into methods of
the Socket/ServerSocket classes, e.g. Socket.getLocal XXX().

EJP

Sam wrote:
Esmond Pitt <es*********@no t.bigpond.com> wrote in message news:<W6******* ************@ne ws-server.bigpond. net.au>...
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

Esmond,

My thinking was: whatever OS routine is responsible for delivering
payload data to a listening application over a specific port doesn't
need to know what IP address the data came over, it only needs to
deliver it to the correct port. The IP address doesn't even exist at
the transport layer. So to my mind the only the way the requirement
could be achieved was to somehow set up separate ports with the same
port number for each listening interface, which seemed unlikely.

However, what I failed to account for is that Java Sockets speak with
IP at some level, because for example they can specify the remote IP
in the Socket class. So, from there it's not much of a jump to realize
it probably has a way to understand the local IP address, as well.

I'm still unclear as to the mechanics of it, though. I'm pretty sure
that on Windows Jave uses JNI to interact with the WinSock API to
handle it's network functionality. But, my real question is, what
exactly is a "port" anyway, except a numeric label which has a
constraint that it can't be re-used within a single IP address? In the
end, it may be that it's simply a question of processes - the Winsock
API or corresponding OS module probably tracks some internal table
which matches a port to a specific interface, and as long the
combination of the two is different from all other entries in its
table, no problem. In the end, what I thought was "unlikely" is
probably what actually occurs - the OS tracks a separate port for each
interface, or at least has the capability of doing so. (DISCLAIMER:
the preceding is pure speculation...)

Regards,
Sam90


Jul 17 '05 #12
On Thu, 29 Jul 2004 06:43:46 GMT, Esmond Pitt
<es*********@no tatall.bigpond. com> wrote or quoted :
hat's what it does, it can't do anything
else. A socket is identified by its IP address, its port number, and its
protocol number.


I'm not sure if that is what you meant to imply, but there is no
"protocol number" field in a TCP/IP header.

see http://mindprod.com/jgloss/tcpip.html

The host computer simply knows which protocol it is hosting on each
port.

You can't have two different protocols hosted on the same port, e.g.
HTTP and FTP.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Jul 17 '05 #13
Roedy

There is a protocol number field in an IP packet header, and I was
talking about IP at the time. Obviously in the case of TCP the protocol
number is the TCP protocol number, 6. BTW the statement that 'the host
computer simply knows which protocol it is hosting on each port' needs
further work. At the TCP level the host neither knows nor cares about
the protocol; at the IP level you *can* have several protocols on the
same port, e.g. ICMP, UDP, TCP.

EJP

Roedy Green wrote:
On Thu, 29 Jul 2004 06:43:46 GMT, Esmond Pitt
<es*********@no tatall.bigpond. com> wrote or quoted :

hat's what it does, it can't do anything
else. A socket is identified by its IP address, its port number, and its
protocol number.

I'm not sure if that is what you meant to imply, but there is no
"protocol number" field in a TCP/IP header.

see http://mindprod.com/jgloss/tcpip.html

The host computer simply knows which protocol it is hosting on each
port.

You can't have two different protocols hosted on the same port, e.g.
HTTP and FTP.


Jul 17 '05 #14
Sam
Esmond Pitt <es*********@no tatall.bigpond. com> wrote in message news:<41******* *******@notatal l.bigpond.com>. ..
Sam

IP delivers data via sockets. That's what it does, it can't do anything
else. A socket is identified by its IP address, its port number, and its
protocol number. In the case of TCP, the socket is one end of a
connection whose other end is defined by *its* IP address and port
number. So, for the data to go anywhere at all IP has to know the local
address and port number *first*, i.e. it scans the table of sockets
somehow to find one with the target IP address/port/protocol no.
Esmond,

If it does it this processing all in one go based on a single match of
ip address/port, then what's the point of having a layered protocol
stack? i.e, the link layer checks if the mac address is correct for
the current host, and if so passes the data upward to the IP module.
The IP module assures that the packet is intended for the current host
based on its IP address, and if so passes it up to the transport
module - regardless of port. Then the transport module looks for a
listening process on the destination port in its process/port table,
and if it finds one, then it passes the data to that process - if not
listening process is found, an ICMP error message is sent back to the
originating host. Isn't this the fundamental flow of a packet up the
tcp/ip protocol stack? If so, it seems to differ from the process you
describe, which seems to describe a single process for matching
ip/port.

Regards,
Sam90
specified in the incoming IP packet. Then, the data is passed to that
socket, and the local IP address (& port) of any socket can be retrieved
via the Sockets API.

This is nothing to do with Java, it all happens at the IP layer. See W R Stevens 'TCP/IP Illustrated' for details. The only
time Java comes into it is by mapping the Sockets API into methods of
the Socket/ServerSocket classes, e.g. Socket.getLocal XXX().

EJP

Sam wrote:
Esmond Pitt <es*********@no t.bigpond.com> wrote in message news:<W6******* ************@ne ws-server.bigpond. net.au>...
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

Esmond,

My thinking was: whatever OS routine is responsible for delivering
payload data to a listening application over a specific port doesn't
need to know what IP address the data came over, it only needs to
deliver it to the correct port. The IP address doesn't even exist at
the transport layer. So to my mind the only the way the requirement
could be achieved was to somehow set up separate ports with the same
port number for each listening interface, which seemed unlikely.

However, what I failed to account for is that Java Sockets speak with
IP at some level, because for example they can specify the remote IP
in the Socket class. So, from there it's not much of a jump to realize
it probably has a way to understand the local IP address, as well.

I'm still unclear as to the mechanics of it, though. I'm pretty sure
that on Windows Jave uses JNI to interact with the WinSock API to
handle it's network functionality. But, my real question is, what
exactly is a "port" anyway, except a numeric label which has a
constraint that it can't be re-used within a single IP address? In the
end, it may be that it's simply a question of processes - the Winsock
API or corresponding OS module probably tracks some internal table
which matches a port to a specific interface, and as long the
combination of the two is different from all other entries in its
table, no problem. In the end, what I thought was "unlikely" is
probably what actually occurs - the OS tracks a separate port for each
interface, or at least has the capability of doing so. (DISCLAIMER:
the preceding is pure speculation...)

Regards,
Sam90

Jul 17 '05 #15
Sam wrote:

If it does it this processing all in one go based on a single match of
ip address/port,


Sam

If you want to know how TCP works please read the reference I mentioned
before. I didn't say say anything about everything happening in one go,
this is more guesswork on your part. Obviously the data is passed from
the NIC to IP to TCP and obviously lots of processing happens on the
way, but an IP socket is *defined* by its protocol number, an IP
address, and a port number, and these socket attributes are available
all the way up the stack and indeed to the application.

EJP

Jul 17 '05 #16
Sam
Esmond Pitt <es*********@no tatall.bigpond. com> wrote in message news:<41******* *******@notatal l.bigpond.com>. ..
Sam wrote:

If it does it this processing all in one go based on a single match of
ip address/port,


Sam

If you want to know how TCP works please read the reference I mentioned
before. I didn't say say anything about everything happening in one go,
this is more guesswork on your part. Obviously the data is passed from
the NIC to IP to TCP and obviously lots of processing happens on the
way, but an IP socket is *defined* by its protocol number, an IP
address, and a port number, and these socket attributes are available
all the way up the stack and indeed to the application.

EJP


EJP,

I'm not convinced what you've been saying is entirely accurate. For
example, you previously mentioned that data doesn't go anywhere unless
there is a socket available. You also state that socket attributes are
available all the way up the stack.

I've just reviewed pp. 19-21 of Steven's TCP Illustrated, Volume II.
He describes the progress of a UDP packet up the protocol stack, from
the hardware interrupt which launches the nic driver, to the passing
of the data by the driver to the IP layer, which in turn passes it to
the UDP input routine.

The first mention of sockets is made in the description of the UDP
input routine. It uses the port on the UDP header to locate a PCB
Control block, and when it finds a match "This will be the PCB created
by our call to socket, and the inp_socket member of this PCB points to
the corresponding socket structure, allowing the received data to be
received by the correct socket". My reading this has the data going
as least as far as the UDP (transport) layer, and no socket available
to the stack until then.

This appears to contradict your assertion about the packets not going
anywhere without a socket - it gets as far as the transport layer -
and about the socket being available throughout the protocol stack -
it's only looked up at the transport layer.

The whole point of the layered architecture is to prevent one layer
from having to contend with data that belongs in another layer, and
that's been cited as one of the main reason for TCP/IP's great
success.

Regards,
Sam90
Jul 17 '05 #17
This thread is somewhat difficult to follow, so I'll assume the question is
the typical, "how do I have an RMI server bind to a specific network
interface?"

The answer is you use java.rmi.regist ry.LocateRegist ry, create a
RMIServerSocket Factory that is bound to a specific interface using
java.net.Networ kInterface.

If my assumption is incorrect, please ignore.

--
Tony Morris
http://xdweb.net/~dibblego/
Jul 17 '05 #18
Sam

OK, if UDP or TCP or ICMP or whatever transport layer matches the socket
to the inbound IP packet, instead of IP, the local IP address *still*
doesn't get 'thrown away as the data goes up the protocol stack',
because it must still be there in the IP packet for TCP or UDP to do
this matching, and it must also available be in the socket descriptor to
be matched. Can we agree on that?

This also means that TCP, UDP, ICMP &c do indeed deal with IP data, &
just goes to show that TCP/IP implementation layering is not as clean as
you might like to think. Certainly IP doesn't have to deal with TCP
data, but the other way round does happen (no worse than a derived class
using methods from its base class really).

Of course Stevens vol II only describes one implementation. I don't know
that a 'cleaner' implementation where IP despatches packets to sockets
is infeasible either ... What *would* be infeasible is the
implementation you seem to keep imagining where TCP can't access the IP
header or the local IP address: otherwise the OP's situation wouldn't
work, and it does; also Socket.getLocal Address() == getsockname()
couldn't work either.

Anyway basta cosi.

EJP

Jul 17 '05 #19
Tony Morris wrote:
This thread is somewhat difficult to follow, so I'll assume the question is
the typical, "how do I have an RMI server bind to a specific network
interface?"

The answer is you use java.rmi.regist ry.LocateRegist ry, create a
RMIServerSocket Factory that is bound to a specific interface using
java.net.Networ kInterface.

If my assumption is incorrect, please ignore.


That works for the registry itself, but for specific RMI servers you
also have to provide *them* with a ServerSocketFac tory, probably the
same one, and you have to use the appropriate IP address or interface
name when binding them to the registry.

Jul 17 '05 #20

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

Similar topics

2
3726
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
43160
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
2349
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
2540
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
9579
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
9422
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
10035
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...
1
9984
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,...
0
9851
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8863
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...
1
7403
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
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3949
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

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.