>In article <. com>
> <> wrote:
>>I'm trying to write a program that reads data from a network stream.
>>I would like the program to read all available data in the buffer and
>>then process the data. I do not want the program to hang unless there
>>is no data in the buffer. ...
In article <ef286l$19n$>
Walter Roberson <> wrote:
>You can't do that in standard C. Standard C does not offer any method
>to check to see whether input is waiting, other than trying to read
>it and ending up waiting for it.
>
>Standard C does not know anything about network streams, which
>suggests that you might be operating in an environment that is
>augmented with additional functionality. If so, your environment
>might offer you a way to do what you want. You should consult
>a newsgroup more specific to your platform.
Indeed.
>[(e.g., you might want to examine POSIX's,
>fcntl(fileno(pData),F_SETFL,FNONBLK) ]
But this is, I think, not going to be the right solution. (In
particular, combining O_NONBLOCK [not FNONBLK] with fread() is
a bad idea, on POSIX systems.)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it
http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.