Hello everyone,<br><br>I&#39;m trying to send a python-string via a QTcpSocket. I am using this structure:<br><br>----------------------------------------<br>block = QtCore.QByteArray()<br>stream = QtCore.QTextStream(block, QtCore.QIODevice.WriteOnly)<br>

stream &lt;&lt; myPythonString<br><br clear="all">if myTcpSocket.isWritable():<br>    myTcpSocket.write(block)<br>-----------------------------------------<br><br>However, it now seems that there are some corrupted characters at the beginning of the bytearray (or textstream) :-S..<br>

<br>A solution for this can be to call stream.flush() just before I stream myPythonString to it..<br>In code:<br><br>----------------------------------------<br>
block = QtCore.QByteArray()<br>
stream = QtCore.QTextStream(block, QtCore.QIODevice.WriteOnly)<br>stream.flush() # removes the ascii dump successfully<br>stream &lt;&lt; myPythonString<br>
<br clear="all">if myTcpSocket.isWritable():<br>    print &quot;writing data to &quot;, str(socket.peerAddress().toString())<br>
    myTcpSocket.write(block) # crashes here<br>-----------------------------------------<br><br>But at this point, the program crashes at the last line when actually writing to the socket.. How come? I found out that this crash can be reproduced anywhere when calling stream.string() just after streaming myPythonString to the textstream..<br>

In code:<br><br>----------------------------------------<br>
block = QtCore.QByteArray()<br>
stream = QtCore.QTextStream(block, QtCore.QIODevice.WriteOnly)<br>stream.flush() # removes the ascii dump<br>stream &lt;&lt; myPythonString<br>print str(stream.string()) # crashes here already..<br>
<br clear="all">if myTcpSocket.isWritable():<br>    print &quot;writing data to &quot;, str(socket.peerAddress().toString())<br>
    myTcpSocket.write(block)<br>-----------------------------------------<br><br>How on earth can this be?<br><br>-- <br>Nick Gaens<br>