Forum: Ruby ip address of client from GServer#serve

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E8ea895a56fb370bd3f678f774fe290a?d=identicon&s=25 Julien Biard (brasco)
on 2009-01-19 15:10
(Received via mailing list)
Hi,

I would like to know if there is a way to take the ip address of client
from GServer#serve.

Regards,

Julien
753dcb78b3a3651127665da4bed3c782?d=identicon&s=25 Brian Candler (candlerb)
on 2009-01-19 15:44
Julien Biard wrote:
> I would like to know if there is a way to take the ip address of client
> from GServer#serve.

Try this:

def serve(myClient)
  p myClient.peeraddr
end
E8ea895a56fb370bd3f678f774fe290a?d=identicon&s=25 Julien Biard (brasco)
on 2009-01-19 16:01
(Received via mailing list)
thanks, it works.
I should have considered the GServer#serve parameter as a socket and not
just as an io (cf http://www.ruby-doc.org/core/classes/GServer.html).
This topic is locked and can not be replied to.