Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Addrinfo#to_sockaddr

addrinfo.to_sockaddr => string

returns the socket address as packed struct sockaddr string.

Example
Addrinfo.tcp("localhost", 80).to_sockaddr
#=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
See also #to_s #unix? #socktype #unix_path also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0