XDR and select?

Joel Loo loo at mcc.com
Thu Mar 30 13:13:50 AEST 1989


I have been using the xdr (external data representation) on a network of
SUN3 workstations for passing of data. I like it a lot. I created xdr
record streams around sockets and use the socket as abstract data stream
(?). I like in particular: xdr routines are bidirectional, saving the time
needed to write pairs of input/output routines.

I encounter one problem which I hope some of you can help:

In a program I have a few sockets and each has an xdr struct associated.
Naturally I used a loop and call 'select' to wait for input from the
sockets. Whenever a socket becomes alive, its corresponding xdr is used to
read a record and process it. However, records got choked up in the xdr
internal buffers once in a while because xdr routines often reads pass
record boundary (for the sake of filling up internal buffer). I appreciate
the xdr buffering effort but this chokes up small records in the buffer
very often. A choked record is processed only later when the next record
in the stream writes into the socket and trigger the 'select' call.

Although no records got lost, the application I am working on needs to
process the records as soon as they come in. Is there any suggestion to
get rid of this choking?

Thanks in advance.

PS. I had tried 'xdrrec_eof' hoping that it is written precisely for this
situation, ie. to test if the internal buffer is empty; but it seems to do
something else.  Also, specifying the buffer size to 1 char (or smaller
than the smallest record size) helps but are there some other ways? If
possible I would like to keep using xdr, select, and not touching the xdr
internals.

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.sys.sun mailing list