method
addr
v2_2_9 -
Show latest stable
-
0 notes -
Class: IPSocket
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (38)
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
addr(*args)
public
Returns the local address as an array which contains address_family, port, hostname and numeric_address.
If reverse_lookup is true or :hostname, hostname is obtained from numeric_address using reverse lookup. Or if it is false, or :numeric, hostname is same as numeric_address. Or if it is nil or ommitted, obeys to ipsocket.do_not_reverse_lookup. See Socket.getaddrinfo also.
TCPSocket.open("www.ruby-lang.org", 80) {|sock| p sock.addr #=> ["AF_INET", 49429, "hal", "192.168.0.128"] p sock.addr(true) #=> ["AF_INET", 49429, "hal", "192.168.0.128"] p sock.addr(false) #=> ["AF_INET", 49429, "192.168.0.128", "192.168.0.128"] p sock.addr(:hostname) #=> ["AF_INET", 49429, "hal", "192.168.0.128"] p sock.addr(:numeric) #=> ["AF_INET", 49429, "192.168.0.128", "192.168.0.128"] }