Skip to content
Back to top
View this page
Edit this page

# Socket

class serialx.platforms.serial_socket.SocketSerial

  Bases: `BaseSerial`

  Synchronous serial interface over a TCP socket.

  __init__(*args, connect_timeout=10.0, **kwargs)

    Initialize socket serial port.

    Parameters:

      - args (Any)

      - connect_timeout (float | None)

      - kwargs (Any)

    Return type:

      None

  property is_open: bool

    Check if the serial port is open.

  property connect_timeout: float | None

    Get the connection timeout in seconds.

  num_unread_bytes()

    Return the number of bytes waiting to be read.

    Return type:

      int

  num_unwritten_bytes()

    Return the number of bytes waiting to be written.

    Return type:

      int

class serialx.platforms.serial_socket.SocketSerialTransport

  Bases: `BaseSerialTransport`

  Serial transport over a TCP socket.

  __init__(loop, protocol)

    Initialize the socket serial transport.

    Parameters:

      - loop (AbstractEventLoop)

      - protocol (Protocol)

    Return type:

      None

  write(data)

    Write data to the socket.

    Parameters:

      data (bytes | bytearray | memoryview)

    Return type:

      None

  pause_reading()

    Pause reading from the socket transport.

    Return type:

      None

  resume_reading()

    Resume reading from the socket transport.

    Return type:

      None

  is_closing()

    Return whether the transport is closing.

    Return type:

      bool

  abort()

    Abort the transport immediately.

    Return type:

      None

  close()

    Close the transport.

    Return type:

      None

  get_write_buffer_size()

    Get the number of bytes currently in the write buffer.

    Return type:

      int

  get_write_buffer_limits()

    Get the write buffer low and high water marks.

    Return type:

      tuple[int, int]

  set_write_buffer_limits(high=None, low=None)

    Set the write buffer low and high water marks.

    Parameters:

      - high (int | None)

      - low (int | None)

    Return type:

      None

  can_write_eof()

    Return whether the underlying TCP transport supports EOF.

    Return type:

      bool