PDA

View Full Version : In QTcpServer->listen() How is a port chosen automatically ?



scieck
23rd April 2011, 04:38
Hi,
The documentation says: "If port is 0, a port is chosen automatically"
Does it mean completely randomly ?
or amongst available ports ?
or in which automatic way ?

cheers
_andrea

ChrisW67
23rd April 2011, 10:42
Binding to port zero on Linux/UNIX/Windows allows the operating system to choose a port that is free (it knows which ports are free). The port number will be above 1024, i.e. not system reserved, but otherwise indeterminate.

I imagine you can retrieve the port number allocated with the serverPort() method.