您好我在pyqt4中创建了一个带Qtcpsocket的tcp服务器。我很容易收到客户的消息。但是此服务器无法向客户端发送消息。请让我知道我在哪里做错了。
def sendMessage(self):
print('send message is called')
message = 'OKVTdddddssssddssss'
reply = QtCore.QByteArray()
reply.append(message)
stream = QtCore.QDataStream(reply, QtCore.QIODevice.WriteOnly)
stream.setVersion(QtCore.QDataStream.Qt_4_0)
stream.writeUInt16(0)
stream.writeQString(message)
stream.device().seek(0)
stream.writeUInt16(reply.size() - SIZEOF_UINT16)
self.tcp.write(reply)