-
-
Save etehtsea/17b43d824b7be907c02a49b199689070 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
» s = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0).tap { |s| s.bind(Socket.sockaddr_in(0, "127.0.0.1")) } | |
=> #<Socket:0x4e7dc304> | |
» Socket.unpack_sockaddr_in(s.getsockname) | |
/127.0.0.1:0 | |
0 | |
=> [0, "127.0.0.1"] | |
» s.local_address | |
/127.0.0.1:64454 | |
64454 | |
=> #<Addrinfo: localhost:64454 TCP> | |
» Socket.unpack_sockaddr_in(s.getsockname) | |
localhost/127.0.0.1:64454 | |
64454 | |
=> [64454, "127.0.0.1"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment