Hello i try to use this but i have a problem, i never see the server reply:
def identify(self):
SIZEOF_UINT16 = 2
self.socket = QtNetwork.QTcpSocket()
il_mio_nick = QtCore.QString('NICK mynick\n')
invio_identificazione = QtCore.QString('/msg nickserv identify
my_password')
self.request = QtCore.QByteArray()
stream =QtCore.QDataStream(self.request, QtCore.QIODevice.WriteOnly)
stream.setVersion(QtCore.QDataStream.Qt_4_4)
stream.writeUInt16(0)
stream << il_mio_nick << invio_identificazione
stream.device().seek(0)
stream.writeUInt16(self.request.size()- SIZEOF_UINT16)
if self.socket.isOpen():
self.socket.close()
self.label.setText('Mi sto connettendo')
self.socket.connectToHost('irc.eden-irc.net', 6667)
if self.socket.waitForConnected (1000):
self.label.setText('connesso')
self.nextBlockSize = 0
self.socket.write(self.request)
self.request = None
self.leggo_risposta()
else :
errore = self.socket.SocketError()
self.label.setText(QtCore.QString("Errore:
%1").arg(self.socket.errorString()))
self.socket.close()
def leggo_risposta(self):
stream = QtCore.QDataStream(self.socket)
stream.setVersion(QtCore.QDataStream.Qt_4_4)
SIZEOF_UINT16 = 2
while True:
if self.nextBlockSize == 0:
if self.socket.bytesAvailable() < SIZEOF_UINT16:
break
self.nextBlockSize = stream.readUInt16()
if self.socket.bytesAvailable() < self.nextBlockSize :
break
risposta =QtCore.QString
stream >> risposta
self.textEdit.setText(risposta)
self.nextBlockSize = 0
I use wireshark to log the network traffic and i see the the connection is ok i
log also the reply from the server but i i'm not able to put it in the textEdit.
Debugging the project i never see reply from the server why the socket never
read the reply?
Thanks
Luca
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt