Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct syntax for reading binn object from socket #13

Closed
markvai opened this issue Sep 2, 2017 · 1 comment
Closed

correct syntax for reading binn object from socket #13

markvai opened this issue Sep 2, 2017 · 1 comment
Labels

Comments

@markvai
Copy link

markvai commented Sep 2, 2017

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
Copy link
Collaborator

kroggen commented Sep 3, 2017

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");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants