Skip to content

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

class method

Socket.pack_sockaddr_un

(::String sockpath) -> ::String
Socket.sockaddr_un(path) => sockaddr
Socket.pack_sockaddr_un(path) => sockaddr

Packs path as an AF_UNIX sockaddr string.

Example
Socket.sockaddr_un("/tmp/sock") #=> "\x01\x00/tmp/sock\x00\x00..."
See also .pack_sockaddr_in .pair .new .sockaddr_in also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0