0

Using PyQt4 and Qt4.1, Python 3.7.2, latest PyInstaller

I have two applications (c++ and python) which communicate via udp localhost, port 2340 and port 2341) On both applications I am bounding the ports with

self.SocketIn.bind(QtNetwork.QHostAddress.LocalHost, 2340, QtNetwork.QUdpSocket.ReuseAddressHint)
self.SocketIn.readyRead.connect(lambda: print("Hallo")

and (on c++ side)

SocketOut->bind(QHostAddress::LocalHost, 2340, QUdpSocket::ReuseAddressHint);

Both applications return true and the states are also "4", which means they are in BoundState.

Now the problem: If I start at first the python application it is working. The c++ app receives messages on port 2341 and sends messages on 2340. The python app receives messages on port 2340 and sends messages on port 2341. If I start the c++ application first, the python app won't trigger the readyRead signal on port 2340 anymore. Like I said all boundStates are there (python app, c++ app, -> ports 2340, 2341) and the messages are really send from the c++ app (seen in wireshark)

What is the clue here?

EDIT: Now i realized that the other way around is the same behaviour. It seems that the receiving side must be initialized first in order to work!

raffro1337
  • 11
  • 2

1 Answers1

0

I had a similar problem. The QUdpSocket documentation states

If you just want to send datagrams, you don’t need to call bind() .

When I removed the bind from the sending side, I could start and stop the sender and receiver in any order and it worked.

Janine
  • 13
  • 2
  • 7