PDA

View Full Version : No working readyRead() signal in QUdpSocket



tokotoko
27th January 2021, 07:17
Hi,

I want to use QUdpScoket Multicast ,but readyRead() signal don't emit.
Confirming that datagrams can be received at WireShark and SocketDebbugger.
Firewall is Invalidation. Bind, connect, joinMulticast is true. I never get socket errorString.
But readyRead() is don't emit. Why ?



void Udp::fnUdpSetting(QString localIP,quint16 multicastPort,QString multicastIP)
{
m_pUdpSockRecv = new QUdpSocket(this);


connect(m_pUdpSockRecv, SIGNAL( readyRead() ), this, SLOT( fnUdpRecvData() ));

if( m_pUdpSockRecv->bind( QHostAddress( localIP ) , multicastPort, QUdpSocket::DefaultForPlatform) ){
if( m_pUdpSockRecv->joinMulticastGroup( QHostAddress( multicastIP ) )) {
qDebug() << "Connection Success";
} else {
qDebug() << "Join Error";
}
}
else {
qDebug() << "Bind Error";
}

}



The IP and Port I'm using are
localIP: 192.168.0.122
multicastPort: 49871
multicastIP 239.0.0.15


I don't get any errors or anything, so I have no idea.
Can someone help me?
Thanks.

stampede
3rd February 2021, 20:07
I'd try to connect to stateChanged (https://doc.qt.io/qt-5/qabstractsocket.html#stateChanged) and errorOccurred (https://doc.qt.io/qt-5/qabstractsocket.html#errorOccurred) signals of the socket.
Other than that it's hard to say without seeing the rest of the code, maybe you accidentally destroy the socket object somewhere ? first of all, is the event loop running ?