[Qt-interest] Problem with FD_SET and select
Thiago Macieira
thiago at kde.org
Fri Sep 18 08:30:48 CEST 2009
Em Sexta-feira 18. Setembro 2009, às 04.33.58, Flavio Ceolin escreveu:
> void ThreadCommRead::run()
> {
> fd_set fds;
> int aux=0;
> FD_ZERO(&fds);
> FD_SET(m_handle,&fds);
> while(running){
> aux = select(m_handle+1,&fds,NULL,NULL,&timer);
> if(aux>0){
> m_mutex->lock();
> if((nbytes = read(m_handle,buffer,BUFFERSIZE))>0)
> emit dataRead(buffer,nbytes);
> m_mutex->unlock();
> }
> }
> }
>
Where is timer set? It has to be reset at every loop, because the select(2)
call could modify it.
According to the manual of select(2), it returns zero if the timer expires. It
looks like that's what's happening in your example.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
Qt Developer Days 2009 | Registration Now Open!
Munich, Germany: Oct 12 - 14 San Francisco, California: Nov 2 - 4
http://qt.nokia.com/qtdevdays2009
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090918/72816da0/attachment.bin
More information about the Qt-interest-old
mailing list