def attach(self, detach_other_clients=False, color_depth=ColorDepth.DEPTH_8_BIT):
assert isinstance(detach_other_clients, bool)<EOL>self._send_size()<EOL>self._send_packet({<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': detach_other_clients,<EOL>'<STR_LIT>': color_depth,<EOL>'<STR_LIT>': os.environ.get('<STR_LIT>', '<STR_LIT>'),<EOL>'<STR_LIT:data>': '<STR_LIT>'<EOL>})<EOL>with raw_mode(sys.stdin.fileno()):<EOL><INDENT>data_buffer = b'<STR_LIT>'<EOL>stdin_fd = sys.stdin.fileno()<EOL>socket_fd = self.socket.fileno()<EOL>current_timeout = INPUT_TIMEOUT  <EOL>try:<EOL><INDENT>def winch_handler(signum, frame):<EOL><INDENT>self._send_size()<EOL><DEDENT>signal.signal(signal.SIGWINCH, winch_handler)<EOL>while True:<EOL><INDENT>r = select_fds([stdin_fd, socket_fd], current_timeout)<EOL>if socket_fd in r:<EOL><INDENT>data = self.socket.recv(<NUM_LIT>)<EOL>if data == b'<STR_LIT>':<EOL><INDENT>o = Vt100_Output.from_pty(sys.stdout)<EOL>o.quit_alternate_screen()<EOL>o.disable_mouse_support()<EOL>o.disable_bracketed_paste()<EOL>o.reset_attributes()<EOL>o.flush()<EOL>return<EOL><DEDENT>else:<EOL><INDENT>data_buffer += data<EOL>while b'<STR_LIT>' in data_buffer:<EOL><INDENT>pos = data_buffer.index(b'<STR_LIT>')<EOL>self._process(data_buffer[:pos])<EOL>data_buffer = data_buffer[pos + <NUM_LIT:1>:]<EOL><DEDENT><DEDENT><DEDENT>elif stdin_fd in r:<EOL><INDENT>self._process_stdin()<EOL>current_timeout = INPUT_TIMEOUT<EOL><DEDENT>else:<EOL><INDENT>self._send_packet({'<STR_LIT>': '<STR_LIT>'})<EOL>current_timeout = None<EOL><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>signal.signal(signal.SIGWINCH, signal.SIG_IGN)<EOL><DEDENT><DEDENT>
Attach client user interface.