Results 1 to 7 of 7

Thread: QWebSocketServer howto move new connections to a own thread

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2013
    Posts
    29
    Thanks
    4
    Thanked 4 Times in 2 Posts

    Default Re: QWebSocketServer howto move new connections to a own thread

    Quote Originally Posted by wysota View Post
    Bad idea. I could crash your app in seconds.
    Why?

    Quote Originally Posted by wysota View Post
    If the docs says it can't be used from another thread then it can't......
    The same thing is mentioned for QTcpServer for the function QTcpServer::nextPendingConnection but it is possible to overwrite QTcpServer::incomingConnection for this.
    I just wanted to know if there is a possiblity to do it.

    Why threads? -> Maybe every connection can do a blocking operation in my application and therefore I want to decouple them from the rest of the application/listener.

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

    Default Re: QWebSocketServer howto move new connections to a own thread

    Quote Originally Posted by M4chin3 View Post
    Why?
    Because usually the number of threads you can spawn per process or per user is limited. By opening a large number of concurrent connections I'd either force your app to run out of threads or starve it by flooding it with context switching.

    Why threads? -> Maybe every connection can do a blocking operation in my application and therefore I want to decouple them from the rest of the application/listener.
    Then you want to perform that blocking operation in another thread (or better yet using a limited thread pool) and not push the whole communication there. You can decouple whatever you want decoupled by encapsulating it in an object. You don't require threads for that.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2013
    Posts
    29
    Thanks
    4
    Thanked 4 Times in 2 Posts

    Default Re: QWebSocketServer howto move new connections to a own thread

    By decoupling I meant moving the task to another thread to avoid blocking the whole program. But basically you're right, I can move the blocking tasks to threads and keep the connections all together within another thread. I'm not worrying about the number of threads shouldn't be so many, but I'm giving the limited thread pool a thought.

    Thanks!

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

    Default Re: QWebSocketServer howto move new connections to a own thread

    Quote Originally Posted by M4chin3 View Post
    I'm not worrying about the number of threads shouldn't be so many
    Right... and 640kB or RAM should be enough for anybody
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: QWebSocketServer howto move new connections to a own thread

    Quote Originally Posted by M4chin3 View Post
    The same thing is mentioned for QTcpServer for the function QTcpServer::nextPendingConnection but it is possible to overwrite QTcpServer::incomingConnection for this.
    I think that part of the docs is actually outdated. Somewhen during Qt5 it became possible to move QTcpSocket instances to different threads.

    Cheers,
    _

Similar Threads

  1. Replies: 11
    Last Post: 12th September 2012, 16:25
  2. Replies: 1
    Last Post: 4th September 2012, 14:13
  3. multithread thread don't move
    By lzpmail in forum Qt Programming
    Replies: 11
    Last Post: 28th March 2011, 09:09
  4. Replies: 1
    Last Post: 30th July 2010, 07:23
  5. howto Processing GUI events until a thread exits
    By doggrant in forum Qt Programming
    Replies: 0
    Last Post: 5th October 2009, 15:50

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
  •  
Qt is a trademark of The Qt Company.