Module: OS::Mac::UNIXSocketExt Private

Extended by:
T::Helpers
Defined in:
extend/os/mac/utils/socket.rb

Overview

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Wrapper around UNIXSocket to allow > 104 characters on macOS.

Instance Method Summary collapse

Instance Method Details

#sockaddr_un(path) ⇒ String

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:



15
16
17
18
19
20
21
22
23
24
25
# File 'extend/os/mac/utils/socket.rb', line 15

def sockaddr_un(path)
  if path.bytesize > 252 # largest size that can fit into a single-byte length
    raise ArgumentError, "too long unix socket path (#{path.bytesize} bytes given but 252 bytes max)"
  end

  [
    path.bytesize + 3, # = length (1 byte) + family (1 byte) + path (variable) + null terminator (1 byte)
    1, # AF_UNIX
    path,
  ].pack("CCZ*")
end