Module: Utils::UNIXSocketExt Private

Extended by:
T::Generic
Defined in:
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.

Class Method Summary collapse

Class Method Details

.open(path, &_block) {|unix_socket| ... } ⇒ T.type_parameter(:U)

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:

  • path (String)
  • _block (T.proc.params(arg0: UNIXSocket).returns(T.type_parameter(:U)))

Yields:

  • (unix_socket)

Returns:

  • (T.type_parameter(:U))


17
18
19
20
21
22
23
# File 'utils/socket.rb', line 17

def self.open(path, &_block)
  socket = Socket.new(:UNIX, :STREAM)
  socket.connect(sockaddr_un(path))
  unix_socket = UNIXSocket.for_fd(socket.fileno)
  socket.autoclose = false # Transfer autoclose responsibility to UNIXSocket
  yield unix_socket
end

.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:



26
27
28
# File 'utils/socket.rb', line 26

def self.sockaddr_un(path)
  Socket.sockaddr_un(path)
end