def handle_connection(self, clientsock):
        """Receives a message and calls the corresponding message handler"""
        connection = self.connectionpool.get_connection_by_socket(clientsock)
        try:
            for message in connection.received_bytes():
                if self.debug: self.logger.write("State", "received %s" % str(message))
                if message.type == MSG_STATUS:
                        if self.debug: self.logger.write("State",
                                                         "Answering status message %s"
                                                         % self.__str__())
                        messagestr = pickle.dumps(self.__str__())
                        message = struct.pack("I", len(messagestr)) + messagestr
                        clientsock.send(message)
                        return False
                # Update nodeliveness
                if message.source.type != NODE_CLIENT:
                    self.nodeliveness[message.source] = time.time()
                    if message.source in self.replicas:
                        self.replicas[message.source] = 0

                # add to receivedmessages
                self.receivedmessages.append((message,connection))
                self.receivedmessages_semaphore.release()
                if message.type == MSG_CLIENTREQUEST or message.type == MSG_INCCLIENTREQUEST:
                    self.connectionpool.add_connection_to_peer(message.source, connection)
                elif message.type in (MSG_HELO, MSG_HELOREPLY, MSG_UPDATE):
                    self.connectionpool.add_connection_to_peer(message.source, connection)
            return True
        except ConnectionError as e:
            return False
dataset/ETHPy150Open denizalti/concoord/concoord/node.py/Node.handle_connection/original