how to find the right socket
Unsolved
General and Desktop
-
Hey guys,
I have the following code:
com_PingTest::com_PingTest(QList<QHostAddress> lIPAddresses, QObject *parent) : QObject(parent) { for(int iItr = 0; iItr < lIPAddresses.length(); iItr++) { QUdpSocket *sNewUDPsocket = new QUdpSocket(this); if(sNewUDPsocket->bind(lIPAddresses.at(iItr),1234)) qDebug() << lIPAddresses.at(iItr).toString() << "good"; else qDebug()<< lIPAddresses.at(iItr).toString() << "not good"; connect(sNewUDPsocket,SIGNAL(readyRead()),this,SLOT(readyRead())); lOfUDPSockets.append(sNewUDPsocket); } }
Now, how do I know which socket has called the readyRead - function?
Is there a possibility to get the socket descriptor of the socket that emitted the readyRead signal?Thanks!
-
- add
#include <functional>
- change the
readyRead()
slot toreadyRead(QUdpSocket* socket)
- change
connect(sNewUDPsocket,SIGNAL(readyRead()),this,SLOT(readyRead()));
toconnect(sNewUDPsocket,&QUdpSocket::readyRead,this,std::bind(&com_PingTest::readyRead,this,sNewUDPsocket));
- add