correct syntax for reading binn object from socket
markvai opened this issue · 1 comments
markvai commented
Hi,
can you write what is the correct syntax for reading a binn object from a socket?
what i am trying is:
sending:
binn * obj = binn_object();
binn_object_set_int32(obj, (char*)"dst_enclave", 306768318);
int socket = clSockFd;
if (send(socket, binn_ptr(obj), binn_size(obj), 0) != binn_size(obj)) {
printf("SENDER -- failed to send msg1 to dest\n");
abort();
}
binn_free(obj);
reading:
binn * obj = binn_object();
if (recv(servSockFd, binn_ptr(obj), binn_size(obj), 0) < 0) {
printf("LISTENER -- failed to read msg1 from src\n");
abort();
}
int test = binn_object_int32(obj, (char*)"dst_enclave");
but i am getting 0 in test.
kroggen commented
Just use read()
as you are used to, reading the data to a buffer.
Then read the binn from the buffer, like this:
int test = binn_object_int32(buf, "dst_enclave");