XDR record streams and 'select'

Joel Loo loo at mcc.com
Fri Mar 31 13:19:38 AEST 1989


I am using the XDR implementation on a SUN3 workstation.   It  is
an  excellent interface for passing complex data structures among
processes across the network.  I  like  one  particular  property
about  XDR  routines:  they are bidirectional! I do not having to
spend time writing pairs of routines for input and output.

I encountered one problem maybe some of you can help:

I build XDR record streams around  socket  connections  (abstract
data  sockets  (?)).  For a certain program, I have more than one
such XDRs reading input from other processes via sockets.  Natur-
ally  I use a loop with a 'select' call to pick the active socket
fd and do input on the associated  XDR  and  process  the  input.
Everything  was  fine  until  some  data was choked up within XDR
internals: an XDR reads pass the boundary into  the  next  record
from the socket for the sake of filling up its internal buffer. I
appreciate the buffering effort but the next record happens to be
a  short  one that fits nicely into the buffer. And, the problem:
my 'select' call does not know about the pending  record  in  the
XDR  internal  buffer.  The 'select' call blocks and wait happily
for the next record to come before it knows  there  is  something
not processed.

I have used 'xdrrec_eof' hoping that it is written precisely  for
this   situation, ie. to check for non-empty internal buffer. But
this routine seems to do something else.

Any suggestion? (Best if  I  can  still  use  'select',  XDR  and
without touching XDR intestines.)

PS. Changing the buffer size to 1 char helps but  there  must  be
some intelligent ways of solving this.

--------------------------------------------------------------------
Joel Loo Peing Ling composed on Wed Mar 8 13:07:52 CST 1989
--------------------------------------------------------------------
MCC                            |   Email:  loo at sw.mcc.com
3500 West Balcones Centre Dr.  |   Voice:  (512)338-3680 (O)
Austin, TX 78759               |           (512)343-1780 (H)



More information about the Comp.unix mailing list