Client

Client that communicates with Cadence through a server.

class socad.client.Client(sock=None)

A client that handles Cadence Virtuoso requests.

This client receives data from Cadence (through a server) and processes that data. It then gather the processed data and send it back to Cadence through the server. It sends data in JSON format and the received data should also be serialized in JSON.

Parameters:sock (object, optional) – socket to use for the connection (default: None).
close()

Close the socket.

recv_bytes(n_bytes)

Receive a specified number of bytes through a socket.

Parameters:n_bytes (int) – number of bytes to receive.
Raises:ConnectionError – if the socket connection is broken.
Returns:received bytes stream.
Return type:bytes
recv_data()

Receive an object through a socket.

1 - Receive the first 4 bytes of data, which contains the data length;

2 - Receive the data, serialized in JSON, and decode it;

3 - Convert the received data in an object.

Raises:
Returns:

decoded and de-serialized received data.

Return type:

dict

run(host, port)

Start the client.

Parameters:
  • host (str) – remote socket IP address.
  • port (int) – remote socket port.
Raises:

ConnectionError – if can’t connect to server.

Returns:

remote socket name.

Return type:

list

send_data(obj)

Send an object through a socket.

1 - Serialize the object in JSON and encode the string;

2 - pack the serialized object length in an unsigned int (I)[4 bytes], and big-endian byte order (>) (this way the object size message has always the same size);

3 - send the data.

Parameters:

obj (dict) – object to send.

Raises: