# Ip address of client from GServer#serve

**URL:** https://rubytalk.org/t/ip-address-of-client-from-gserver-serve/51251
**Category:** ruby-talk
**Created:** [19 January 2009 14:08 UTC](https://rubytalk.org/t/ip-address-of-client-from-gserver-serve/51251 "2009-01-19T14:08:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Julien\_Biard](https://avatars.discourse-cdn.com/v4/letter/j/6de8d8/32.png) [@Julien\_Biard](https://rubytalk.org/u/Julien_Biard)
#### Post date: [19 January 2009 14:08 UTC](https://rubytalk.org/t/ip-address-of-client-from-gserver-serve/51251/1 "2009-01-19T14:08:37Z")

</div>

Hi,

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

Regards,

Julien

---

<div class="post-metadata">

### Author: ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://rubytalk.org/u/Brian_Candler)
#### Post date: [19 January 2009 14:43 UTC](https://rubytalk.org/t/ip-address-of-client-from-gserver-serve/51251/2 "2009-01-19T14:43:11Z")

</div>

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)  
&nbsp;&nbsp;p myClient.peeraddr  
end

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

### Author: ![Julien\_Biard](https://avatars.discourse-cdn.com/v4/letter/j/6de8d8/32.png) [@Julien\_Biard](https://rubytalk.org/u/Julien_Biard)
#### Post date: [19 January 2009 14:59 UTC](https://rubytalk.org/t/ip-address-of-client-from-gserver-serve/51251/3 "2009-01-19T14:59:32Z")

</div>

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\](http://www.ruby-doc.org/core/classes/GServer.html%5C)).

> **···**
>
> On Mon, Jan 19, 2009 at 3:43 PM, Brian Candler \<b.candler@pobox.com\> wrote:
> 
> > 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  
> > --  
> > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
