Results 1 to 6 of 6

Thread: QUdpSocket High rate message reading

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2010
    Posts
    77
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QUdpSocket High rate message reading

    Hi, everybody!

    I have a strange issue in working with QUdpSocket and readyRead signal, I can say it's not working as I think,

    I create a QUdpSocket and bind it to some port , connect the readyRead signal to my slot and I read all the pending datagram as below

    Qt Code:
    1. if(!udp_listener)
    2. {
    3. udp_listener = new QUdpSocket(this);
    4. connect(udp_listener, SiGNAL(readyRead()), this, SLOT(readBuffers(), Qt::QueuedConnection);
    5. // the rate of receiving data is 10 msec if i dont put Qt::QueuedConnection, it didn't receive any more signal after first received. why ???
    6. // change the rate of data to 1 sec and this code work well without Qt::QueuedConnection !!!
    7. }
    8.  
    9. udp_lister.bind(Any, 5555);
    To copy to clipboard, switch view to plain text mode 

    and my readBuffers code
    Qt Code:
    1. void readBuffers() {
    2. QString buffer;
    3. while(udp_listener->hasPendingDatagrams()) {
    4. QByteArray received;
    5. received.resize(udp_listener->pendingDatagramSize());
    6. udp_listener->readDatagram(received, received.size(), 0,0);
    7. buffer.append(received);
    8. // Do some job in 1 msec on buffer and take data from buffer
    9. if(/* some works done */) buffer.clear(); // almost every time my buffer got cleared
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    I thought my problems solved with using of Qt::QueuedConnection but today I add another widget to my project and updated it every 100 msec and I don't know how but my slot didn't signaled any more after 2 seconds.

    If I change my timer interval or sending data rate to 1 sec, everything is fine.

    all of my classes and my widgets live in main program's thread and I don't use another thread, but it seems I should!
    so why signals dropped by Qt eventloop.
    I check my socket state and it did'nt change after Bound.

    Thanks in advance
    Last edited by danics; 2nd August 2016 at 12:28.

Similar Threads

  1. BroadCast message from Linux to windows using QUDPsocket
    By arunkumaraymuo in forum Qt Programming
    Replies: 1
    Last Post: 25th April 2015, 19:55
  2. Blink LED for 5 seconds with 1Hz rate
    By sammey_geek in forum Newbie
    Replies: 4
    Last Post: 21st September 2013, 12:57
  3. Replies: 2
    Last Post: 23rd April 2013, 18:34
  4. baud rate
    By adriana in forum Newbie
    Replies: 5
    Last Post: 6th May 2011, 17:18
  5. High performance large file reading on OSX
    By mikeee7 in forum Qt Programming
    Replies: 2
    Last Post: 15th October 2009, 14:18

Tags for this Thread

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.