duhber / rcf-cpp

Automatically exported from code.google.com/p/rcf-cpp
0 stars 0 forks source link

Specify client IP address #30

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have one RcfServer listening on 10.0.0.1 and two clients on the same machine 
with two IP addresses available: 10.0.0.2 and 10.0.0.3. I want one client bound 
to 10.0.0.2 and the other one to 10.0.0.3.
At this moment, the server identifies both clients coming from the same machine 
(that's OK) and with the same IP address (that's bad).
Is it possible to specify an IP address to be used by a RcfClient object? 
On the server, in order to obtain the client's address, I use:

RCF::getCurrentRcfSession().getRemoteAddress().string();

Of course, on different machines, everything works fine.

Original issue reported on code.google.com by rafael.a...@gmail.com on 12 Nov 2010 at 12:55

GoogleCodeExporter commented 9 years ago
Thanks for reporting this. It's not possible in RCF 1.2 to specify a specific 
client side network interface, but I've added it to the list of features for 
RCF 1.3.

Original comment by jarl.lin...@gmail.com on 15 Nov 2010 at 1:33

GoogleCodeExporter commented 9 years ago
OK, thanks for the answer.

I could work around this issue if I could know, on the server, the IP of the 
RcfServer handling the remote object. Now, I get this information using the 
function RCF::getCurrentRcfSession().getRemoteAddress().string() to get the 
client's IP address using the object. Is there any similar function to get the 
RcfServer IP address serving the object?

For instance I have an object, and I export it through two RcfServers:

/* Servers */
RCF::RcfServer server_1(RCF::TcpEndpoint(ip_1, port));
RCF::RcfServer server_2(RCF::TcpEndpoint(ip_2, port));
/* Exported object */
MyClass objRef;
server_1.bind<I_MyClass>(objRef);
server_2.bind<I_MyClass>(objRef);

Could the own object objRef know which RcfServer is using it? For example, 
getting through some function the IP associated to that server instance.

Once again, thank you.

Original comment by rafael.a...@gmail.com on 16 Nov 2010 at 7:51

GoogleCodeExporter commented 9 years ago
From within your server implementation functions, you can call:

RCF::getCurrentRcfSession().getRcfServer()

, and that will give you the RcfServer the call came in on... Hope that helps.

Original comment by jarl.lin...@gmail.com on 17 Nov 2010 at 1:04

GoogleCodeExporter commented 9 years ago
Hello again. I've tried RCF 1.3 including "setLocalIp" in order to bind the 
client to a specific local interface. It seems to work so I think this issue 
could be closed.

Thank you for your time and work. 

Original comment by rafael.a...@gmail.com on 17 Jun 2011 at 12:27