Results 1 to 4 of 4

Thread: QTcpSocket makes my thread pause

  1. #1
    Join Date
    Jun 2010
    Posts
    100
    Thanks
    13
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTcpSocket makes my thread pause

    Hi all!

    I wrote a program that uses multiple threads and I am having some pauses in the middle of one of them that I can't understand.

    One of the threads reads digital inputs from a machine to see if buttons are pressed and the other thread has a class that writes/reads tcp packages from a server that controls a laser.

    These 2 threads are created by the same class but don't share anything. What happens is that when I call the line "tcpsocket->waitForReadyRead()" the thread that checks for the digital inputs just pauses and when the command is finished runs again.

    Other than this problem the program runs perfectly but I realy need to read digital inputs while the program is waiting for an answer from the server.

    Any tips?

    Thanks!

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

    Default Re: QTcpSocket makes my thread pause

    That's what waitForReadyRead() does -- it waits (pauses) until a readyRead signal would be received.
    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
    Jun 2010
    Posts
    100
    Thanks
    13
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTcpSocket makes my thread pause

    Quote Originally Posted by wysota View Post
    That's what waitForReadyRead() does -- it waits (pauses) until a readyRead signal would be received.
    But why does it pause a totally unrelated thread?

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

    Default Re: QTcpSocket makes my thread pause

    Maybe it is not as unrelated as you think. Check the thread affinity of the socket object. Make sure it is what you think it is.
    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.


Similar Threads

  1. QTcpSocket no signal when using in a thread
    By mentalmushroom in forum Qt Programming
    Replies: 9
    Last Post: 10th April 2011, 07:50
  2. QTcpSocket deamon-thread
    By mihau in forum Qt Programming
    Replies: 8
    Last Post: 18th March 2011, 07:58
  3. Replies: 16
    Last Post: 7th October 2009, 08:17
  4. is qtcpsocket a thread
    By ersin.ozkan in forum Qt Programming
    Replies: 1
    Last Post: 11th March 2009, 09:39
  5. What makes something not thread safe?
    By tgreaves in forum Newbie
    Replies: 9
    Last Post: 20th February 2009, 20:16

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.