Method: Gem::Net::HTTP#ipaddr

Defined in:
lib/rubygems/vendor/net-http/lib/net/http.rb

#ipaddrObject

Returns the IP address for the connection.

If the session has not been started, returns the value set by #ipaddr=, or nil if it has not been set:

http = Gem::Net::HTTP.new(hostname)
http.ipaddr # => nil
http.ipaddr = '172.67.155.76'
http.ipaddr # => "172.67.155.76"

If the session has been started, returns the IP address from the socket:

http = Gem::Net::HTTP.new(hostname)
http.start
http.ipaddr # => "172.67.155.76"
http.finish


1351
1352
1353
# File 'lib/rubygems/vendor/net-http/lib/net/http.rb', line 1351

def ipaddr
  started? ?  @socket.io.peeraddr[3] : @ipaddr
end