I was debugging ganglia and came through sending data using XDR through UDP channel.
I found the second argument of the function xdrmem_create ( xdrs, addr, size, op)
strange.
Where the syntax of the arguments are given as:
XDR *xdrs;
char *addr;
u_int size;
enum xdr_op op;
The reference of this function is here.
As you can see, the second argument (xdrs) of this function is a character array. And this is similarly declared in one of the ganglia's function as char msgbuf[GANGLIA_MAX_MESSAGE_LEN];
.
After calling above function as xdrmem_create(&x, msgbuf, GANGLIA_MAX_MESSAGE_LEN, XDR_ENCODE);
in ganglia , appropriate data in the ganglia's specific structure (cb->msg
) is encoded to XDR format by calling the function xdr_Ganglia_value_msg(&x, &(cb->msg))
where x
is an XDR
type of variable.
Later, to send the encoded data through UDP channel, the function Ganglia_udp_send_message( udp_send_channels, msgbuf, len);
is called.
To understand how this XDR data is sent, I tried to print the output of the content of msgbuf
using fprintf
but it always print nothing in spite of the fact that it is a character array . And it is also evident that the encoded data is sent successfully.
So, my question is, How data encoded into XDR format is being sent through UDP channel here?
I have pasted a part of code from ganglia here. You can see from the line 131 to 136 for your reference.