Hans-Peter Jansen schreef:
Hmm.. That doesn't seem to work :-S..On Monday 23 November 2009, 15:19:06 Nick Gaens wrote:Hans-Peter Jansen schreef:[...]---------------------------- def __init__(self): self.server = QtNetwork.QTcpServer(self) self.server.serverPort = 55555 self.server.newConnection.connect(self.clientConnecting) self.server.listen() # defaults to QHostAddress.Anydef clientConnecting(self): # used by the "server" if self.server.hasPendingConnections(): connectingClient = self.server.nextPendingConnection() connectingClient.readyRead.connect(self.receiveData) def connectToClient(self, ip): # used by the "client" socket = QtNetwork.QTcpSocket() socket.readyRead.connect(self.receiveData) socket.connectToHost(QtNetwork.QHostAddress(ip), 55555) # ip of server if socket.waitForConnected(5000): print "Connected!" ----------------------------[...]How odd that I receive this mail *the moment* my code started working :-P. I found that the serverPort may not be overwritten. I removed this assignment: self.server.serverPort = 55555Assigning properties this way usually won't work in PyQt (although Phil tackles this already). try this: self.server.listen(QtNetwork.QHostAddress.Any, 55555)and the clients now can connect to the server w/o any problem.. Downside is that the port is random..Pete _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt self.server.listen(QtNetwork.QHostAddress.Any, 55555): TypeError: argument 1 of QTcpServer.listen() has an invalid type How can this be? I've got PyQt4.6.2 on WinXP, Python 2.6.4 |
_______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt