libmuscle.mcp.tcp_util module

exception libmuscle.mcp.tcp_util.SocketClosed[source]

Bases: Exception

Raised when trying to read from a socket that was closed.

libmuscle.mcp.tcp_util.is_disconnect(exception: Exception) bool[source]

Checks whether this is a disconnect or another problem.

libmuscle.mcp.tcp_util.recv_all(socket: socket, length: int) Buffer[source]

Receive length bytes from a socket.

Parameters:
  • socket – Socket to receive on.

  • length – Number of bytes to receive.

Raises:
libmuscle.mcp.tcp_util.recv_frame(socket: socket) Buffer[source]

Receives a frame as length + data.

Parameters:

socket – The socket to receive on

Returns:

The received data.

Raises:

RuntimeError – If there was an error receiving the data.

libmuscle.mcp.tcp_util.recv_int64(socket: socket) int[source]

Receives an int as a 64-bit signed little endian number.

Parameters:

socket – The socket to receive on.

Raises:
libmuscle.mcp.tcp_util.send_frame(socket: socket, data: Buffer) None[source]

Sends a frame as length + data.

Parameters:
  • socket – The socket to send on

  • data – The data to send

Raises:

RuntimeError – If there was an error sending the data.

libmuscle.mcp.tcp_util.send_int64(socket: socket, data: int) None[source]

Sends an int as a 64-bit signed little endian number.

Parameters:
  • socket – The socket to send on.

  • data – The number to send.

Raises:

RuntimeError – If there was an error sending the data.