connect_address()
Instance Public methods
Returns an address of the socket suitable for connect in the local machine.
This method returns self.local_address, except following condition.
-
IPv4 unspecified address (0.0.0.0) is replaced by IPv4 loopback address (127.0.0.1).
-
IPv6 unspecified address (::) is replaced by IPv6 loopback address (::1).
If the local address is not suitable for connect, SocketError is raised. IPv4 and IPv6 address which port is 0 is not suitable for connect. Unix domain socket which has no path is not suitable for connect.
Addrinfo.tcp("0.0.0.0", 0).listen {|serv| p serv.connect_address #=> #<Addrinfo: 127.0.0.1:53660 TCP> serv.connect_address.connect {|c| s, _ = serv.accept p [c, s] #=> [#<Socket:fd 4>, #<Socket:fd 6>] } }
Please login to continue.