I use Drb to talk from a number of clients to a central server. I have logging on the server that records the method called and the arguments that it was called with. I'd like to include the IP address that the Drb request came from, but I can't find any way to get that information. Is the information available? If so how do I get it? If not, does anybody know why not? thanks, Anthony Wright.
on 2011-10-10 12:33
on 2011-10-11 22:22
Anthony Wright wrote in post #1025900: > I use Drb to talk from a number of clients to a central server. I have > logging on the server that records the method called and the arguments > that it was called with. I'd like to include the IP address that the Drb > request came from, but I can't find any way to get that information. Is > the information available? If so how do I get it? If not, does anybody > know why not? The nice thing about DRb is it's all pure ruby. Digging about a bit: def main_loop Thread.start(@protocol.accept) do |client| @grp.add Thread.current Thread.current['DRb'] = { 'client' => client , 'server' => self } So in your method handler, try looking at Thread.current['DRb']['client']. I think that will be a DRbTCPSocket object with a peeraddr method. Simple demo (client and server in the same code): require "drb" class Foo def doit return "You are #{Thread.current['DRb']['client'].peeraddr.inspect}" end end DRb.start_service("druby://0.0.0.0:9999", Foo.new) o = DRbObject.new_with_uri("druby://127.0.0.1:9999") puts o.doit
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.