1

I've got a problem with modifying the port number while the socket is listening for python clients. This is for an application on Windows.

Does anyone know if it's possible to stop a port from listening, from the main thread, while the port listening is in another thread?

The socket lives in its own thread, not the main thread. And I can not modify a socket from other thread than current thread. I tried by using signals and slots but it did not work. I am using the thread-worker approach currently. Does any one have any suggestions?

JokerMartini
  • 5,674
  • 9
  • 83
  • 193

1 Answers1

1
  1. The target thread must be an unmodified QThread, i.e. it must spin an event loop.

  2. The socket I/O should reside in a QObject that you have moved to that thread.

  3. You can then easily execute arbitrary code in the target thread, invoked from any other thread.

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313