Exemplo n.º 1
0
    def __send(self, command, *args):

        """
        Sends the given command to the given socket and returns the answer.
        """

        xdr.send(self.__sock, command, *args)

        return xdr.recv(self.__sock)
Exemplo n.º 2
0
            # something really unexpected has happened
            except Exception:
                try:
                    xdr.send_error(clientsock)
                except Exception:
                    import traceback; traceback.print_exc()

        if (self.__block_timeout[clientsock] > 0):
            self.__block_timeout[clientsock] -= 1

            if (self.__block_timeout[clientsock] == 0):
                callback()
            return True

        try:
            data = xdr.recv(clientsock)

        # no data on connected socket
        except socket.error:
            return True

        # socket disconnected
        except xdr.XDRError:
            clientsock.close()
            return False

        message = data[0]
        args = data[1:]

        try:
            handler = self.__message_handlers[message]