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. QUdpSocket application

QUdpSocket application

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.0k 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.
  • P Offline
    P Offline
    Prosaicon
    wrote on last edited by
    #1

    Hi,

    I want to make a datacollector that gets data from my device and put it in a mySql database. I know the protocol (udp based with seq.no and CRC16) for the device, and I know the Sql stuff. I could go with the QUdpsocket and ReadyData signal, but my device expect an acknowledge in return. I also have to accept a request for data from the Sql database from my device.

    The 2 protocol senarios:
    @
    Device: DataCollector:


    WriteData --> Store in SQL
    Acknowledge <-- Stored succesfull

    or

    Device: DataCollector:


    ReadData --> Retrieve from SQL
    Data + ACK <-- Data + retreived succesfull
    @

    So my question is: Is the sinal/slot approach the way to go or how would you solve this task ?

    Regards prosaicon

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vezprog
      wrote on last edited by
      #2

      You could do either.

      If you want to send the data and receive in the same function, that's totally up to you. You would just need to send it, and call waitForReadyRead() after you send and pass in a timeout that way. Depeding how long the transaction takes and how long it takes your receiver to process/gather/send...if you do it this way, it might be better to do it in a thread and send updates to the ui via signals in slots so your not blocking your applications main thread for a extended amount of time. Just subclass a QThread.

      Another way would be to connect the ready read slot up to the socket, and have a QTimer for a timeout. When you send, if the data has not been received by the time the QTimer timeout fires, then you can display an error. Else, kill the timer in the ready read slot so it doesn't fire after successful transmission.

      You could also use a tcp socket...which will allow you to know that the connection to the receiver is successful.

      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