def read_data(self): try: for client_id, client_socket in enumerate(self.clients): if client_socket.bytesAvailable() > 0: stream = QDataStream(client_socket) stream.setVersion(QDataStream.Qt_5_9) stream.readUInt32() client_data= stream.readQString() self.return_data_to_clients(client_id, client_data) except Exception as e: print(e)
def read_data(self): try: stream =QDataStream(self.socket) stream.setVersion(QDataStream.Qt_5_9) while True: if self.socket.bytesAvailable() <= 0: break stream.readUInt32() text_from_server = stream.readQString() if self.text_widget: print('display_text') print(text_from_server) self.text_widget.append(text_from_server) except Exception as e: print(e)