Obtaining ip address of client socket in ruby

Discussion in 'Ruby' started by Victor Rosillo, Nov 24, 2007.

  1. How can I obtain the ip address of the originating (client) socket ,
    in a server/client socket ruby program?

    What ruby library is fitted with a class/ method to do this?
    How can it be done using ruby?

    I would appreciate some sample code.
    Victor Rosillo, Nov 24, 2007
    #1
    1. Advertising

  2. 2007/11/24, Victor Rosillo <>:
    > How can I obtain the ip address of the originating (client) socket ,
    > in a server/client socket ruby program?
    >
    > What ruby library is fitted with a class/ method to do this?
    > How can it be done using ruby?
    >
    > I would appreciate some sample code.


    http://www.ruby-doc.org/docs/ProgrammingRuby/html/lib_network.html

    robert

    --
    use.inject do |as, often| as.you_can - without end
    Robert Klemme, Nov 24, 2007
    #2
    1. Advertising

  3. Victor Rosillo

    Bill Kelly Guest

    From: "Robert Klemme" <>
    > 2007/11/24, Victor Rosillo <>:
    >> How can I obtain the ip address of the originating (client) socket ,
    >> in a server/client socket ruby program?
    >>
    >> What ruby library is fitted with a class/ method to do this?
    >> How can it be done using ruby?
    >>
    >> I would appreciate some sample code.

    >
    > http://www.ruby-doc.org/docs/ProgrammingRuby/html/lib_network.html



    sock_domain, remote_port, remote_hostname, remote_ip = socket.peeraddr


    # note: sock_domain is the address family, e.g. "AF_INET"


    Regards,

    Bill
    Bill Kelly, Nov 24, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Justin Ezequiel

    Obtaining the remote ip address

    Justin Ezequiel, Mar 28, 2006, in forum: Python
    Replies:
    3
    Views:
    841
    Peter Hansen
    Mar 28, 2006
  2. Ben Finney

    Re: Obtaining the remote ip address

    Ben Finney, Mar 28, 2006, in forum: Python
    Replies:
    0
    Views:
    462
    Ben Finney
    Mar 28, 2006
  3. Replies:
    0
    Views:
    316
  4. Jean-Paul Calderone
    Replies:
    0
    Views:
    946
    Jean-Paul Calderone
    Jan 27, 2009
  5. Dido Sevilla
    Replies:
    1
    Views:
    215
    Anders Engström
    Feb 23, 2005
Loading...

Share This Page