[PyQt] QtNetwork newbie question
john.stewart at insomniafilm.com
Mon Mar 19 19:22:09 GMT 2012
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)
But then how do access the readAll() for the data thats being sent? Doing the same bit on the tcpSocketReadyReadEmitted function throws an AttributeError.
data = str( self.tcpServer.nextPendingConnection().readAll() )
AttributeError: 'NoneType' objet has no attribute 'readAll'
Again, total beginner at this so sorry if the answer is glaring.
On Mar 18, 2012, at 2:55 PM, Phil Thompson wrote:
> On Sun, 18 Mar 2012 13:40:49 -0700, John Stewart
> <john.stewart at insomniafilm.com> wrote:
>> Hi all,
>> I am trying to write a distributed render manager. The sever would be
>> waiting for incoming connections (other CPUs wishing to be part of the
>> machine pool) and then issue commands to be run on those other CPUs when
>> job is run in the manager via a user.
>> So far, this is what I am using to listen for connections and return
>> class Main(QtGui.QMainWindow):
>> def __init__(self):
>> #init UI
>> #init Network
>> self.tcpServer = QtNetwork.QTcpServer()
>> self.connect(self.tcpServer, QtCore.SIGNAL("newConnection()"),
>> self.newConnectionArrives )
>> def newConnectionArrives(self):
>> self.sock = self.tcpServer.nextPendingConnection()
>> self.connect(self.sock, QtCore.SIGNAL("readyRead()"),
>> def tcpSocketReadyReadEmitted(self):
>> data = str(self.sock.readAll())
>> print data
>> When I try and have two separate clients connect, the first client is
>> ignored and only the second's data is received. Am I going about this
>> wrong way for multiple client connections or is there just something I
> You are rebinding self.sock and so losing any previous connection.
More information about the PyQt