Results 1 to 2 of 2

Thread: In QTcpServer->listen() How is a port chosen automatically ?

  1. #1
    Join Date
    Apr 2011
    Posts
    14
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default In QTcpServer->listen() How is a port chosen automatically ?

    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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,734
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: In QTcpServer->listen() How is a port chosen automatically ?

    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.

  3. The following user says thank you to ChrisW67 for this useful post:

    scieck (23rd April 2011)

Similar Threads

  1. Replies: 1
    Last Post: 21st March 2010, 21:14
  2. QTcpServer and port problem
    By Talei in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2009, 18:01
  3. Replies: 1
    Last Post: 24th November 2008, 09:56
  4. couldn't open fontconfigs chosen font with Xft!!!
    By Kenneth Freidank in forum Qt Programming
    Replies: 0
    Last Post: 5th October 2006, 03:14
  5. Replies: 1
    Last Post: 18th June 2006, 10:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.