Results 1 to 3 of 3

Thread: Handling multiple UDP sockets

  1. #1
    Join Date
    Mar 2006
    Posts
    5
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Question Handling multiple UDP sockets

    My Qt applications typically listen on several UDP sockets. Is it better to have a thread for each socket, or to have a single thread that does a select() on a fd_set of several sockets? Both approaches work, but I don't know which is more efficient.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Handling multiple UDP sockets

    There is no one proper answer to that question. select() in a single thread should be fine and in most cases more efficient than using multiple threads. Especially if processing time of the data received from the socket is short.

  3. #3
    Join Date
    Mar 2006
    Posts
    9
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Handling multiple UDP sockets

    Each approach has its qualities and defects. The select one has speed but isi s more complex to program and have a hardcoded limit to how many sockets it can handle each time (the fd_set struct size).

    I suggest you to look the "Unix Network Programming 3rd" book and accord with yout project choose the more suitable one.

Similar Threads

  1. Handling multiple forms
    By msmihai in forum Qt Programming
    Replies: 4
    Last Post: 6th December 2008, 13:41
  2. how to corss compile for windows in Linux
    By safknw in forum Qt Programming
    Replies: 24
    Last Post: 13th May 2006, 05:23

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.