pex.socket

Package Contents

class pex.socket.Socket

Bases: object

Main class of pex.socket module.

This main class of pex.socket module is intended for providing implementations of socket features.

pack_host(host: str, endian: str = 'little') bytes

Pack host into binary form.

Parameters:
  • host (str) – host to pack

  • endian (str) – byte order (little or big)

Return bytes:

packed host

pack_port(port: int, endian: str = 'little') bytes

Pack port into binary form.

Parameters:
  • port (int) – port to pack

  • endian (str) – byte order (little or big)

Return bytes:

packed port

static port(port: int) int

Convert port using htons().

Parameters:

port (int) – port to convert

Return int:

converted port

static host(host: str) int

Convert host using inet_aton().

Parameters:

host (str) – host to convert

Return int:

converted host