Results 1 to 2 of 2

Thread: how to read all datagram packets or limit the no of datagram receiving

  1. #1
    Join Date
    Aug 2015
    Qt products
    Qt5 Qt/Embedded

    Default how to read all datagram packets or limit the no of datagram receiving

    Language C++
    SDK Qt5.5
    OS : LINUX Ubuntu 14.04
    Overview of a problem: MY qt application in c++ is receiving udp packets from Webcam from another computer . On receiving frames as udp packets it perform some other task. It all works fine but sometimes when there is sudden change of light, the camera send large number of packets to my end and Qt application fails to read all the packets and as a result Qt readyread signal is not emitted. this is expected because Qt docs says so
    Note: An incoming datagram should be read when you receive the readyRead() signal, otherwise this signal will not be emitted for the next datagram.

    Now my question is how would I force my application to read all data. Since its udpackets I dont care if I miss some packets but All i want is readyRead to be emitted every time . I looked at some forum and people suggested to use connect before bind which I am doing but still sometimes Qt failed to emit readyRead and when I use wireshark I can see packets are coming to my port from another computer.
    So my question is how would I force qt application to read all datagrams. One think i can think of is to force Qt socket to ready only certain no of packets but is this possible in Qt? below is my code

  2. #2
    Join Date
    Dec 2009
    New Orleans, Louisiana
    Thanked 153 Times in 150 Posts
    Qt products
    MacOS X

    Default Re: how to read all datagram packets or limit the no of datagram receiving

    The whole purpose of that while loop where you check hasPendingDatagrams() is intended to read all datagrams that have been received, so process all datagrams while hasPendingDatagrams() is true then exit your slot. You should then receive another readyRead signal when new datagrams arrive.

    I don't think you can force the behavior you're looking for, e.g. one readyRead signal for one datagram, etc.
    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. Parsing UDP datagram fields
    By catto in forum Qt Programming
    Replies: 7
    Last Post: 23rd February 2011, 20:16
  2. Reading last datagram in UDP network
    By euch in forum Qt Programming
    Replies: 5
    Last Post: 5th December 2010, 23:21
  3. Reading TCP datagram header by Qt
    By Kill3rReaper in forum Qt Programming
    Replies: 11
    Last Post: 8th June 2010, 12:49
  4. QUdpSocket - how to get destination address of a datagram?
    By nelliekins in forum Qt Programming
    Replies: 0
    Last Post: 17th September 2009, 08:59
  5. UDP datagram receive
    By mdannenb in forum Qt Programming
    Replies: 8
    Last Post: 27th July 2008, 03:30

Tags for this Thread


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.