Results 1 to 15 of 15

Thread: QtNetwork: Why don't I detect incomming connections ? (incomingConnection() is never

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: QtNetwork: Why don't I detect incomming connections ? (incomingConnection() is ne

    Quote Originally Posted by QtExchange View Post
    Somebody knows what's going wrong?
    My advice? Learn to walk before you try to run. Qt's networking classes are asynchronous and don't require multi-threading to work properly.

    If you've read how to properly do threading in Qt, people typically use one of the 1) moveToThread method or 2) subclass QThread and implement your code in the QThread::run() method. You seem to want to do both, which I think demonstrates a lack of understanding regarding how to properly do multi-threading in Qt.

    Scrap the threading altogether and start with a simple QTcpServer that can accept incoming connections, handle reading/writing data to the socket, and handle client disconnects, etc. Do that first before you try to introduce multiple threads or add any other features to your application.

    Good luck.
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: QtNetwork: Why don't I detect incomming connections ? (incomingConnection() is ne

    Quote Originally Posted by jefftee View Post
    If you've read how to properly do threading in Qt, people typically use one of the 1) moveToThread method or 2) subclass QThread and implement your code in the QThread::run() method. You seem to want to do both, which I think demonstrates a lack of understanding regarding how to properly do multi-threading in Qt.
    Can you explain why you are opposed to following the best practices when it comes to multi-threading in Qt? Subclassing QThread *and* using the moveToThread approach is not something that you'll find in any (working) example.

    Glad that you have it working for now, but I would still personally adopt one of the QThread subclass approach or the moveToThread approach, not both.
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

Similar Threads

  1. QTcpServer - how to refuse incomming connection
    By atomic in forum Qt Programming
    Replies: 5
    Last Post: 19th August 2015, 13:31
  2. Replies: 1
    Last Post: 14th March 2014, 06:29
  3. Replies: 8
    Last Post: 11th September 2010, 10:41
  4. Replies: 1
    Last Post: 4th February 2009, 01:53
  5. Drag incomming localurl !=linux not work kde
    By patrik08 in forum Qt Programming
    Replies: 6
    Last Post: 11th December 2006, 15:23

Tags for this Thread

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.