7.4.2.2. pymodaq_utils.serialize.mysocket module
- class pymodaq_utils.serialize.mysocket.Socket(socket: socket = None)[source]
Bases:
SocketCustom Socket wrapping the built-in one and added functionalities to make sure message have been sent and received entirely
Methods
check_receiving(bytes_str)First read the 4th first bytes to get the total message length Make sure to read that much bytes before processing the message
check_sended(data_bytes)Make sure all bytes are sent through the socket :param data_bytes: :type data_bytes: bytes
Convenience function to convert permitted objects to bytes and then use the check_sended method
- check_receiving(bytes_str: bytes)[source]
First read the 4th first bytes to get the total message length Make sure to read that much bytes before processing the message
See check_sended and check_sended_with_serializer for a symmetric action
- check_sended(data_bytes: bytes)[source]
Make sure all bytes are sent through the socket :param data_bytes: :type data_bytes: bytes
- check_sended_with_serializer(obj: bytes | str | int | float | complex | list | ndarray[Any, dtype[_ScalarType_co]] | SerializableBase)[source]
Convenience function to convert permitted objects to bytes and then use the check_sended method
Appends to bytes the length of the message to make sure the reception knows how much bytes to expect
For a list of allowed objects, see
Serializer.to_bytes()
- class pymodaq_utils.serialize.mysocket.SocketString(bytes_string: bytes)[source]
Bases:
objectMimic the Socket object but actually using a bytes string not a socket connection
Implements a minimal interface of two methods
- Parameters:
bytes_string (bytes) –
See also
SocketMethods
check_received_length(length)Make sure all bytes (length) that should be received are received through the socket.
get_first_nbytes(length)Read the first N bytes from the socket
to_bytes
- check_received_length(length: int) bytes[source]
Make sure all bytes (length) that should be received are received through the socket.
Here just read the content of the underlying bytes string