Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Addrinfo#to_s

() -> ::String
addrinfo.to_s => string

Alias of #to_sockaddr

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_sockaddr #socktype #protocol #unix? also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0