Can't get QUdpSocket's readyRead() to fire.



  • This is a very common problem and I did a lot of searching before posting this, but none of the similar problem discussions yielded any answers.

    I'm using a simple QUdpSocket, where I get it up and running as such:

    [code]
    // Initialize.
    udpSocket = new QUdpSocket( this );

        if( udpSpec->clientIpAddr != NULL )
            srcUdpAddr = new QHostAddress( udpSpec->clientIpAddr );
        srcUdpPort = udpSpec->clientPort;
        dstUdpAddr = new QHostAddress( udpSpec->fpgaIpAddr );
        dstUdpPort = udpSpec->fpgaPort;
    
        if( udpSpec->clientIpAddr != NULL )
        {
            if( udpSocket->bind( *srcUdpAddr, srcUdpPort ) == false )
               throw( EVENT_RX_UDP_ERROR );
        }
        else
        {
            if( udpSocket->bind( srcUdpPort ) == false )
                throw( EVENT_RX_UDP_ERROR );
        }
    
        connect( udpSocket, SIGNAL( readyRead() ), this, SLOT( UdpDataReady() ) );
    

    [/code]

    Everything initializes fine, and udpSocket->writeDatagram(...) sends it's datagrams, confirmed using WireShark. The destination device replies back with a UDP datagram, again confirmed with WireShark, but my UdpDataReady() slot is never called. I've tried everything I can think of, and no go.

    Not shown is a QTimer that I have in place to timeout on reply datagrams, and I put a debug message in the timer handler that inspected the udpSocket->hasPendingDatagrams(), but it returns false. The socket is properly bound, and again WireShark confirms my incoming datagrams, but no readRead() every fires. It's as the socket binding simply isn't receiving incoming datagrams.

    Thoughts? Am I missing something?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.