Socket#

ignis.utils.listen_socket(sock: socket, errors: Literal['strict', 'replace', 'ignore'] = 'strict') Generator[str, None, None]#

Listen to the socket. This function is a generator.

Parameters:
  • sock (socket) -- An instance of a socket.

  • errors (Literal['strict', 'replace', 'ignore'], default: 'strict') -- The error handling scheme that will be passed to bytes.decode().

Return type:

Generator[str, None, None]

Returns:

A generator that yields responses from the socket.

Example usage:

with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
    sock.connect("path/to/socket.sock")

    for message in utils.listen_socket(sock):
        print(message)
ignis.utils.send_socket(sock: socket, message: str, errors: Literal['strict', 'replace', 'ignore'] = 'strict', end_char: str | None = None) str#

Send a message to the socket.

Parameters:
  • sock (socket) -- An instance of a socket.

  • message (str) -- The message to send.

  • errors (Literal['strict', 'replace', 'ignore'], default: 'strict') -- The error handling scheme that will be passed to bytes.decode().

  • end_char (str | None, default: None) -- The character after which the response is considered fully received (e.g, \n).

Return type:

str

Returns:

The response from the socket.