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. Problem in receiving data on QTcpSocket

Problem in receiving data on QTcpSocket

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.4k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    aashish.lg
    wrote on last edited by
    #1

    Hi,
    I am writting a client application using QTcpSocket, my server has been written using winsock API not using QT.
    from my client socket(QTcpSocket) , whatever be data I am sending to server it is received by server correctly, but when server replied I am not getting any data at client. Even I tried to put bytesAvailable() in a while loop also, but I didnt get any data.

    Note :- At server side I debugged and checked that winsock API send() has been written the data successfully to sockets.
    Please help where I am going wrong.

    Regards
    Ashish

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stevenceuppens
      wrote on last edited by
      #2

      Hi Ashish,

      • In your client application, is the QTcpSocket signal readyRead() emitted when it should receive some data ?
      • Try to debug the QTcpSocket signals connected(), disconnected(), error() ! maybe your client is disconnected at the time it should receive some data from the server..
      • do you have some source ?

      Steven CEUPPENS
      Developer / Architect
      Mobile: +32 479 65 93 10

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aashish.lg
        wrote on last edited by
        #3

        Hi,

        Thanks for your suggestion.
        Actually I am writting a dll that will get loaded by mstsc.exe process on client machine.
        WHile going through the architecture of qt application I came to know that there should be one QApplication object exist, so that I created one QApplication global object, but didnt call exec on that.

        int argc = 0;
        QApplication appObject(argc, NULL);

        Could it be a reason that since I am not calling exec() on my qapplication object , my socket is not receiving the data. If I will call also , what should be the idle place to call that since after that control will not return from this function, and I am writting dll here not exe.

        Is it mandatory to call exec() to even get the signals as well???

        Meanwhile I will try to debug the signals and will come back.

        Regards
        Ashish

        1 Reply Last reply
        0
        • S Offline
          S Offline
          stevenceuppens
          wrote on last edited by
          #4

          That should be the problem!

          Qt Signals & Slots rely's on the event-loop,

          When you initialize a QApplication (Gui) or QCoreApplication (non-Gui), the event-loop starts after you call exec()!

          Now the problem is that a QApplication or QCoreApplication needs to be created in the main thread!
          and that thread is started before your library is loaded...

          good thing is there are some options! :)

          • You can can try to call QApplication::processEvents() from your main applications event loop

          • You can create a second thread and start QApplication::exec() from there

          Steven CEUPPENS
          Developer / Architect
          Mobile: +32 479 65 93 10

          1 Reply Last reply
          0

          • Login

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