From: Ben Giddings Date: 2004-06-10T10:39:05+09:00 Subject: Re: oddities with select On Jun 9, 2004, at 11:43, Ara.T.Howard wrote: > On Wed, 9 Jun 2004, Ben Giddings wrote: > didn't you say something about your socket being in non-blocking mode? > if so, > isn't this just a busy loop since select will keep returning 'true - a > read > will not block': I'm pretty sure that the timeout parameter is what tells select whether or not to block. I think the nonblocking flag only affects reading type operations, like 'recv' or 'read'. If you're using blocking sockets, they wait until there's input, if you're using nonblocking IO, they return immediately, either with data or without. Select is used (I think generally with blocking IO) to test to see if there's any point in attempting a read, to avoid blocking when no data will be read. If there's no serial traffic, it should return my socket if there's input to be read, otherwise it should return nil. > if not in non-blocking mode, perhaps your pattern is bad? what > happens if you > do this: > > >> while true >> if select([@sock], [], [], 0.1) >> retval += @sock.recv(256) > p retval > > > ?? > > do you see retval growing? No, in those cases when there's some data there but 'select' doesn't see it, I don't see anything being appended to 'retval' and I get an empty string back. Thanks for the ideas though, Ben