[SOLVED] QUdpSocket readyRead() signal
-
Im having troubles seeing the readyRead() signal from a bound UDP socket. This is our current code -
The socket is created in our class constructor -
@
// create the actual socket
m_socket = new QUdpSocket(this);// connect activity signal for socket
connect(m_socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
@We then ask our Acquisition class to "start" acquiring some data -
@
bool Acquisition::start()
{
bool ret = true;if (m_socket->bind(5000, QUdpSocket::ShareAddress)) { qDebug() << "Startup... " << m_socket->localAddress().toString() << m_socket->localPort(); connect(m_socket, SIGNAL(readyRead(void)), this, SLOT(dataReady(void))); } else { qDebug() << qt_error_string(); ret = false; } return ret;
}
@Slots -
@
void Acquisition::dataReady()
{
// dummy variables
QHostAddress host;
quint16 port;qDebug() << "dataReady";
// there is some valid data available from UDP
// keep reading until empty (same block size as sent)
while (m_socket->hasPendingDatagrams())
{
// write to our UDP circular buffer
m_socket->readDatagram((char*)m_udpbuffer.Write(), m_msgSize, &host, &port);
}
}
void Acquisition::socketStateChanged(QAbstractSocket::SocketState socketState)
{
qDebug() << "socketStateChanged - " << socketState;
}@
When debugging our code, we hit our socketStateCahnged slot, but we never hit our dataReady slot... We have confirmed with wireshark the fact that there is some data between the devices on the specified port...
UI Elements work as expected (signal/slots) so the mechanism behind all that seems to be ok...
Can anyone suggest what else I am missing?
Ubuntu 12.10 (64-bit)
Qt - 5.0.2
Using Qt Creator to build and debug - 2.7.0 -
yes, bind() is successful (and a signal is fired to indicate the socket changed state to bound)...
I have tried binding to an explicit host address, as well as QHostAddress::Any.
I have tried QUdpSocket::ShareAddress and QUdpSocket::DontShareAddress.
I have have tried wired and wireless adapters.