select() says there's data, read() says there isn't

select() says there's data, read() says there isn't

Post by J.M. Gera » Tue, 19 Mar 1996 04:00:00




Quote:>I have a non-blocking tcp-ip socket that I do a select() on to see if
>there's data. select() says there's data. I do a read() on the socket
>and zero bytes read is returned. I know there should be data to be
>read. And in any case if there wasn't data, read() should return a -1
>with errno=EWOULDBLOCK.
>Most of the time this doesn't happen, but under some circumstances it
>does, with the result being a tight loop with select() and read()
>being called and the process taking up nearly all the CPU cycles.
>Does anyone have any idea what is happening?
>(This is on a Sun SparcStation 5 running Solaris 2.5)

Well, lots of people tell him that this means EOF and the other end
has gone away
BUT
I had a problem with Sun where a select says that there is data, a
read gets a zero return, a second select says there is data again
(perhaps later on!) and a read then gets real data.

So I only counted the other end dead after several consecutive zero
read returns.

 
 
 

select() says there's data, read() says there isn't

Post by Casper H.S. Dik - Network Security Engine » Wed, 20 Mar 1996 04:00:00



>Well, lots of people tell him that this means EOF and the other end
>has gone away

And it does.

Quote:>BUT
>I had a problem with Sun where a select says that there is data, a
>read gets a zero return, a second select says there is data again
>(perhaps later on!) and a read then gets real data.

When using TCP connections?  That shouldn't happen.

It did happen on unix domain sockets in some version sof Solaris 2.x.
It was a bug and it should be fixed by now.

Quote:>So I only counted the other end dead after several consecutive zero
>read returns.

While programming around bugs is sometime necessary, always make sure that
such code does not break when the bug gets fixed.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

select() says there's data, read() says there isn't

Post by Jeff Dickso » Thu, 21 Mar 1996 04:00:00




>>I have a non-blocking tcp-ip socket that I do a select() on to see if
>>there's data. select() says there's data. I do a read() on the socket
>>and zero bytes read is returned. I know there should be data to be
>>read. And in any case if there wasn't data, read() should return a -1
>>with errno=EWOULDBLOCK.

>>Most of the time this doesn't happen, but under some circumstances it
>>does, with the result being a tight loop with select() and read()
>>being called and the process taking up nearly all the CPU cycles.

>>Does anyone have any idea what is happening?

>>(This is on a Sun SparcStation 5 running Solaris 2.5)

Solaris looks like SysV to the programmer and in that case descriptors marked
for non-blocking do indeed return 0 when nothing is available. It has nothing
to do with the brand name.

Jeff S.*son

 
 
 

select() says there's data, read() says there isn't

Post by Giovanni Bea » Fri, 22 Mar 1996 04:00:00


Hi,
someone known if there is a problem related to the select() function
on Solaris 2.3 OS?

Sometimes calling the select() function, with a timeout of some millisecons,
the process stop for a lots of seconds?!?

Thanks for any replay,
*** Giovanni