"Jason E. Aten" <j.e.aten@xxxxxxxxx> schreef: >sample code using nn_recv with NN_MSG: > >https://github.com/glycerine/rust-nanomsg/blob/master/samples/clinano.c Your suggestion is unrelated to the question... Stefan > > > >On Tue, Dec 10, 2013 at 6:27 PM, Stefan de Konink <stefan@xxxxxxxxx> >wrote: > >> I'm currently using a construction where an iov contains a uint32_t >and a >> struct. It make sense that I have to manually set iov_len with the >> appropriate sizes of these objects. >> >> When receiving the object back, I should receive a string-like object >> (instead of the struct). I was expecting I could use a lazy method >let >> nanomsg do my allocation like in the test. >> >> https://github.com/nanomsg/nanomsg/blob/master/tests/msg.c#L81 >> >> For some reason I cannot get the following to work, either response >side >> remains 0x0 or it plainly hangs. >> >> Sender>> >> void *msg = nn_allocmsg(result_length, 0); >> strncpy(msg, result_buf, result_length); >> iov[0].iov_base = &sd; >> iov[0].iov_len = sizeof(uint32_t); >> iov[1].iov_base = &msg; >> iov[1].iov_len = NN_MSG; >> bzero (&hdr, sizeof (hdr)); >> hdr.msg_iov = iov; >> hdr.msg_iovlen = 2; >> nn_sendmsg(sock, &hdr, 0); >> >> <<Receiver >> char *response = NULL; >> uint32_t sd; >> struct nn_msghdr hdr; >> struct nn_iovec iov [2]; >> iov [0]iov_base = &sd; >> iov [0].iov_len = sizeof(uint32_t); >> iov [1].iov_base = &response; >> iov [1].iov_len = NN_MSG; >> bzero(&hdr, sizeof (hdr)); >> hdr.msg_iov = iov; >> hdr.msg_iovlen = 2; >> nn_recvmsg (broker_socket, &hdr, 0); >> >> >> When I change the iov[1] parts on both sides to preallocated buffers, >with >> a fixed size, I do get messages around. Could someone give a hint? >> >> Stefan > > >!DSPAM:1,52a7d1ab190671589787207! -- Verzonden van mijn Android telefoon met K-9 Mail.