Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. why QTcpSocket.read() will block?

why QTcpSocket.read() will block?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 898 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 8090977478 Offline
    8090977478 Offline
    809097747
    wrote on last edited by
    #1

    I'm using the class QTcpSocket to read write data on client mode, but the function QTcpSocket.read() will block there when continues to reading! why?

    1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi!
      Probably because there is no data to read yet.
      How and when do you call read()? Is the socket connected?
      You should connect the QTcpSocket::readyRead() signal to a slot and read the data in that slot.
      See http://doc.qt.io/qt-5/qtnetwork-fortuneclient-example.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved