[comp.lang.c] "fselect

Damian.Cugley@prg.ox.ac.uk (Damian Cugley) (12/14/90)

Writing a fairly simple programs using BSD socket communication, I've
come across a small snag.  

Essentially, I want to do what select(2) does.  Unfortunately, I'm using
stdio buffering on the sockets - which means that there might be input
pending for a particular stream even though there isn't anything pending
for the corresponding fd, which means select() won't find it.

I need to be able to check whether there is any data in the stream
buffers.  The only way I have found to do this is by reading the stdio.h
file and deducing which part of the (in this case) `struct _iobuf'
contains what I'm after.  But this is very very naughty and there is no
particular reason why it should work on any other machine, or even after
future OS releases etc.  I would like to at least pay lip service to
portability.

Is there a portable way to see if there is input pending on a stdio
stream that I've missed?  Or should I simply rewrite the program and do
my own buffering?

Thanks in advance
(That is, "advTHANKSance", in case you were confused...)

 /--------------------------------------------------------------------\
 | Damian Cugley, Programming Research Group, 11 Keble Rd, Oxford, UK |
 | Damian.Cugley@prg.oxford.ac.uk  =or=  ...@oxford.prg in UK         |
 | "It's a good job there are weekdays between weekends to relax in." |
 \--------------------------------------------------------------------/