[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] QtNetwork newbie question
From:       David Boddie <david () boddie ! org ! uk>
Date:       2012-03-19 21:00:08
Message-ID: 201203192200.08576.david () boddie ! org ! uk
[Download RAW message or body]

On Mon Mar 19 19:22:09 GMT 2012, John Stewart wrote:

> So my first thought was to try not binding the nextPendingConnection()
> which looks like this:
>
> self.connect(self.tcpServer.nextPendingConnection(),
> QtCore.SIGNAL("readyRead()"), self.tcpSocketReadyReadEmitted)

OK, this looks fine, I think.

> But then how do access the readAll() for the data thats being sent?  Doing
> the same bit on the tcpSocketReadyReadEmitted function throws an
> AttributeError.
>
> def tcpSocketReadyReadEmitted(self):
>         data = str( self.tcpServer.nextPendingConnection().readAll() )
>         print data
>
> returns
>
> AttributeError: 'NoneType' objet has no attribute 'readAll'

In the tcpSocketReadyReadEmitted() method, you need to call self.sender() to
get the socket object that emitted the signal. If you call the
nextPendingConnection() method again, you may get a different socket object
or None.

It seems that the library removes connections from an internal queue when
you call nextPendingConnection(), so don't call it again until you have
handled the existing connection.

> Again, total beginner at this so sorry if the answer is glaring.

No problem. It's better to ask questions when you're still a beginner!

David
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic