[PyKDE] QSocket.readBlock/QSocket.getch() difference

Phil Thompson phil at river-bank.demon.co.uk
Tue Dec 4 11:23:31 GMT 2001


Michael Ferraro wrote:
> 
>  hello
> 
> in response to a readyRead() signal i check if a socket.bytesAvailable()
> 
> is non-zero at which point I do a socket.readBlock(maxbytes).  The
> buffer returned is zero bytes long and  doesn't have any data in it.
> 
> As a test I followed the readBlock with a loop that makes calls to
> socket.getch() which returns  valid data for the number of
> bytesAvailable.
> 
> I can use getch()s if I have to, but it seems that readBlock should work
> 
> in here. What might I be doing wrong this time, I ask.
> 
> def HandShake (self):
>     socket = self.sender()
>     n = socket.bytesAvailable()
>     if n > 0:
>         hail = socket.readBlock(32)
>         print "readBlock(): ", len(hail), hail        # -- hail is empty
> 
>         for i in range (n):
>             print "getch(): ", socket.getch ()          # -- prints
> valid data

I think it's a bug in QSocket.readBlock() (and QSocket.readLine()).

Should now be fixed in CVS.

Phil




More information about the PyQt mailing list