lkml.org 
[lkml]   [2002]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectHow to tell how much to expect from a fd
From
Date

Does there exist a fcntl or some other way to tell how much data is
"ready to be read" from a fd?

I'm doing this thing where I make the fd non-blocking, select on it,
and then read on it into a buffer that I am pregrowing with realloc.

When the high water mark is up to the top of the buffer, I realloc the
buffer to make it bigger. At present, I'm just adding a constant
value to the buffer size each time I need to do this, but if there was
a way to easily tell how much was "ready to be read" from the fd.

It's not necessary to be exact. If more becomes available between the
time I do this wanted magic and do the read, read's 3rd parameter will
keep me safe, and if it's too low, like if a dup of the fd already
snarfed the data, also no big deal, I'm non-blocking and check the
return value.

So, is this "nice to have" available?


--
Mark Atwood | Well done is better than well said.
mra@pobox.com | http://www.pobox.com/~mra
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:25    [W:0.057 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site