Exemple #1
0
    def handle_socket(self, server):
        if server:
            sock = self.server_sock
            remote_sock = self.client_sock
            cipher = self.decrypt_cipher
        else:
            sock = self.client_sock
            remote_sock = self.server_sock
            cipher = None

        fd = sock.makefile('rb')
        while True:
            data = self.read_message(fd, cipher)
            if not data:
                break

            try:
                if handler.want_reload():
                    reload(handler)
                handler.handle_message(self, server, data)
            except:
                traceback.print_exc()

        remote_sock.shutdown(socket.SHUT_RDWR)
        remote_sock.close()
Exemple #2
0
    def handle_socket(self, server):
        if server:
            sock = self.server_sock
            remote_sock = self.client_sock
            cipher = self.decrypt_cipher
        else:
            sock = self.client_sock
            remote_sock = self.server_sock
            cipher = None

        fd = sock.makefile('rb')
        while True:
            data = self.read_message(fd, cipher)
            if not data:
                break

            try:
                if handler.want_reload():
                    reload(handler)
                handler.handle_message(self, server, data)
            except:
                traceback.print_exc()

        remote_sock.shutdown(socket.SHUT_RDWR)
        remote_sock.close()
Exemple #3
0
  def handle_socket(self, server):
    sock = self.client_sock
    remote_sock = self.server_sock
    if server:
      sock, remote_sock = remote_sock, sock

    fd = sock.makefile()
    while True:
      message = self.read_message(fd)
      try:
        if handler.want_reload():
          reload(handler)
        if server:
          message = handler.handle_server_message(message)
        else:
          message = handler.handle_client_message(message)

        if message is not None:
          self.write_message(remote_sock, *message)
      except:
        traceback.print_exc()