I am trying to serialize a structure in C using XDR and send the serialized data to python over a tcp socket.
I tried using xdrmem_create() to create an XDR stream , call appropriate pack functions and pass the character array to a socket, to achieve this but I get an EOF error on the python side when I try to deserialize the stream .
I was able to achieve this operation successfully between
C server and C client, also between
python server and python client.
I get an error only when I use it with C and Python.
C snippet
#include<rpc/rpc.h>
....
xdrmem_create(&xdrs, arr, MAXLENGTH, XDR_ENCODE);
if(!xdr_person(&xdrs,&pkt)){
printf("ERROR");
};
.....
send(new_fd, arr, MAXLENGTH, 0)
Python snippet
import xdrlib
.....
data = s.recv(4)
unpacker = xdrlib.Unpacker(data)
message_size = unpacker.unpack_uint()
data = s.recv(message_size)
unpacker.reset(data)
person={}
person["name"] = unpacker.unpack_string().decode()
person["age"] = unpacker.unpack_int()
person["flag"] = unpacker.unpack_bool()
person["errEnum"] = unpacker.unpack_enum()
I wonder if there is a mismatch between the way data is serialized in C and Python.