FREAD & FWRITE

dsr at stl.stc.co.uk dsr at stl.stc.co.uk
Mon Nov 13 22:17:44 AEST 1989


I'm using fread and fwrite to send structures over a socket.  One
thing that bothers me is the use of n in fread(ptr, sizeof(*ptr), n, stream);
and in fwrite.

When I write 1 structure and put n=1, then on my read side say that
I'm reading 1 item the program waits until the process dies.  If
however I say I'm writing n=2 but send only one structure then the
information gets through straight away.  Why is this so?  I use fflush
straight after my write but that has no effect.  Also does n refer to
the number of structures or to the number of fields within a
structure?  What would happen if I just made n a large number?



More information about the Comp.lang.c mailing list