May 3, 2012

tyler_cncq tyler_cncq
Lab Rat
1 posts

readyRead signal of QUdpSocket never emit on windows


I had a sample project written by QT works fine on linux(debian),but got trouble when port it to windows.
The problem is that readyRead signal of QUdpSocket never been emitted even it already recv data.i write a timer to check return value of hasPendingDatagrams(), when i send some data to this udp socket from other tools,this return value turn to be true,and pendingDatagramSize return right size of it. why readReady signal didn’t emit?

I notice another things,if the QUdpSocket had been got some data,“delete m_socket” will be blocked. what happened?

there’s code:

header file

  1. class VoiceSession : public QObject
  2. {
  3.  Q_OBJECT
  4. ...
  5. private slots:
  6.     void heartTic();
  7.     void processDatagrams();
  8. }

cpp file

  1. VoiceSession::VoiceSession(const QString& addr,quint16 port,int secHeartTic,QObject* parent)
  2.  : QObject(parent),m_socket(new QUdpSocket(this)),m_timer(new QTimer(this)),m_addr(addr),m_port(port) {
  3.         createUid(); //DEMO
  4.         bool b = m_socket->bind(10199);//QHostAddress(""),10199);
  5.         Q_ASSERT(b);
  6.         logger()->debug("Startup... Server[%1:%2]",addr,(int)port);
  7.         logger()->debug("Startup... Local[%1:%2] UID[%3]",m_socket->localAddress().toString(),m_socket->localPort(),(int)s_uid);
  9.         connect(m_socket,SIGNAL(readyRead()),this,SLOT(processDatagrams()));
  10.         connect(m_timer,SIGNAL(timeout()),this,SLOT(heartTic()));
  12.         heartTic();
  13.         m_timer->setSingleShot(false);
  14.         m_timer->start(secHeartTic*1000);
  15. }
  18. void VoiceSession::processDatagrams() {
  19. ...  // never run
  20. }

1 reply

May 3, 2012

tyler_cncq tyler_cncq
Lab Rat
1 posts

I reinstall window xp,and it works!

  ‹‹ [SOLVED] Can someone please help with QT C++ (How to check for file encryption)???      Filtering "NoDotDot" in filesystem model not working ››

You must log in to post a reply. Not a member yet? Register here!