def recv(self):
LOGGER.debug('<STR_LIT>')<EOL>try:<EOL><INDENT>message_length = struct.unpack('<STR_LIT>', self._socket.recv(<NUM_LIT:4>))[<NUM_LIT:0>]<EOL>message_length -= Connection.COMM_LENGTH<EOL>LOGGER.debug('<STR_LIT>', message_length)<EOL><DEDENT>except socket.timeout:<EOL><INDENT>return None<EOL><DEDENT>comm_status = struct.unpack('<STR_LIT>', self._socket.recv(<NUM_LIT:4>))[<NUM_LIT:0>]<EOL>LOGGER.debug('<STR_LIT>', comm_status)<EOL>bytes_received = <NUM_LIT:0><EOL>message = b"<STR_LIT>"<EOL>while bytes_received < message_length:<EOL><INDENT>if message_length - bytes_received >= <NUM_LIT>:<EOL><INDENT>recv_len = <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>recv_len = message_length - bytes_received<EOL><DEDENT>bytes_received += recv_len<EOL>LOGGER.debug('<STR_LIT>', bytes_received)<EOL>message += self._socket.recv(recv_len)<EOL><DEDENT>if comm_status == <NUM_LIT:0>:<EOL><INDENT>message = self._crypt.decrypt(message)<EOL><DEDENT>else:<EOL><INDENT>return Message(len(message), Connection.COMM_ERROR, message)<EOL><DEDENT>msg = Message(message_length, comm_status, message)<EOL>return msg<EOL>
Receives a message from PS and decrypts it and returns a Message