qt - QUdpSocket::writeDatagram, wait for buffer free -


i'm using method qudpsocket::writedatagram , sending lot of data. when socket full, method return -1. possible somethind select() qudpsocket?

while(!counterlist.empty()) {     countervalueptr value = counterlist.dequeue();     if (mudpsocket->bytestowrite() <= 1<<13)     {         const qbytearray datagram = todatagram(*value);          qint64 sentbytes = 0;         try         {             sentbytes = mudpsocket->writedatagram(datagram, qhostaddress(msettings->getconnectionip()), msettings->getconnectionport());         }         catch(...)         {             emit datalost();             qwarning() << "exception";             throw;         }          qdebug() << datagram;         if(sentbytes == -1)         {             qstring errormsg = geterrormsg(wsagetlasterror());             qwarning() << "socketerror (" << mudpsocket->error() << ") : " << mudpsocket->errorstring() << ". " << errormsg;             emit datalost();         }         else if(sentbytes < datagram.size())         {             qwarning() << "not data sent";             emit datalost();         }         else         {             qdebug() << "counter "<< value->getname() << " sent";             datasent = true;             emit datasent();         }     }     else     {         qwarning() << "socket write buffer full. dropping data.";         emit datalost();     } } 

some times, writedatagram returns -1. when print last error wsagetlasterror prints buffer full.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -