0

What is the best approach to retrieve the port number a QTcpServer in a child process is listening on, assuming we do not want to use fixed port numbers for our TCP servers? So far I have been experimenting with the following two approaches:

  • Start a QTcpServer in the main process and send the port of the TCP server in the child process to the TCP server of the parent process. This works but is cumbersome.
  • Print the port number of the QTcpServer in the child process to stdout and read the standard output from the child process to obtain the port number in the parent process.

Is there another obvious and clean solution that I'm overlooking?

Ton van den Heuvel
  • 10,157
  • 6
  • 43
  • 82

0 Answers0