xdrstdio_create: blocking calls

89 Views Asked by At

I am trying to use the rpc/xdr.h library to develop a simple client/server interaction. I am using the "direct connection", in which the xdr library will receive on the socket and return the translated data:

XDR xdrs_in;
FILE* fstream_in;
fstream_in=fdopen(coonnected_socket, "r");
xdrstdio_create(&xdrs_in, fstream_in, XDR_DECODE);

XDR_data_type a;
xdr_XDR_data_type(&xdrs_in, &a);

With XDR_data_type a type defined and compiled using rpcgen. Supposing that XDR_data_type is really big, and that the other part closes the connection (gracefully or not) during the xdr_XDR_data_type call, will it block waiting for the remaining data? This is a problem that using recv I solve using a SELECT() in order to set a timeout on the waiting time.

I know the most natural answer to this is "try it yourself", but in this way I can't be 100% sure about the behaviour, I can't learn how to solve it, and on the man page I haven't found anything about it.

Thank you for your attention

EDIT

This is the code generated by rpcgen for xdr_XDR_data_type

bool_t
xdr_XDR_data_type (XDR *xdrs, XDR_data_type *objp)
{
    register int32_t *buf;

     if (!xdr_enum (xdrs, (enum_t *) objp))
         return FALSE;
    return TRUE;
}

Yes, it returns a bool_t, but I suppose it depends on the translation itself (i.e. if the integer is a valid integer in the enum mapping), not on the success on receiving or not the data itself.

0

There are 0 best solutions below