I'm trying to send a parcel through a socket to an android application. The client is in libbinder(c++) and the server is an android application that will have to rebuild the parcel. I have been looking for a solution for some time but I don't know how to serialize the parcel and then re-build it on the server side. Any ideas on how this can be done?
Thanks
The part of code where I handle the data
Client
Parcel parc = Parcel();
double three = 5.5;
parc.writeDouble(three);
unsigned char b[sizeof(parc)];
std::memcpy(b, &parc, sizeof(parc));
Then I send like this
send(client, b, sizeof(b), 0);
Server
private int count
private InputStream in = null;
try {
in = socket.getInputStream();
} catch (IOException e) {
e.printStackTrace();
}
try {
count = in.read(bytes);
}catch (IOException e) {
e.printStackTrace();
}
Parcel parcel = Parcel.obtain();
parcel.unmarshall(bytes, 0, bytes.length);
parcel.setDataPosition(0);
double d = parcel.readDouble();
Log.v("----double---", "double" + d);
A good example can be found here.
In general, you will need to make sure that you have the classes available to reconstruct (create from parcel) the objects.