&buf, &sz, NNG_FLAG_ALLOC)) != 0) { fatal("nng_recv", rv); } printf("NODE0: RECEIVED \"%s\"\n", buf); nng_free(buf, sz); } } int node1(const char* url, char* msg) { int sz_msg = strlen(msg) + 1; // '\0' too nng_socket sock...
nng_dial(s, "ipc://nng_test", NULL, 0); nng_msg_alloc(&msg, 0); std::string body = "'LET THERE BE LIGHT' And there was light..."; nng_msg_insert(msg, (void *)body.c_str(), body.length()); nng_sendmsg(s, msg, 0); nng_close(s); } server.cpp #include <nng/nng....
; if ((rv = nng_send(req_sock, request_msg, strlen(request_msg) + 1, 0)) != 0) { fatal("nng_send", rv); } // 接收应答消息 char *response_msg = NULL; size_t response_len; if ((rv = nng_recv(rep_sock, &response_msg, &response_len, NNG_FLAG_ALLOC)) != 0)...
NNG_FLAG_NONBLOCK : 0)) != 0) { fatal("nng_dial", rv); } start = nng_clock(); if ((rv = nng_msg_alloc(&msg, 0)) != 0) { fatal("nng_msg_alloc", rv); } if ((rv = nng_msg_append_u32(msg, msec)) != 0) { fatal("nng_msg_append_u32", rv); } if ((rv =...
Thenng_closefunction is renamed tonng_sock_close, as a heads up... so pay attention to the migration guide! (There is a macro,NNG1_MIGRATIONthat can be set to provide a macro to aid in transition. Summary This is the first "alpha" release of 2.0.0. Note that this is very much ...
req_msg: *mut nng_msg = null_mut(); nng_msg_alloc(&mut req_msg, 0); // Add a value to the body of the message let val = 0x12345678; nng_msg_append_u32(req_msg, val); nng_sendmsg(req_socket, req_msg, 0); // Receive it let mut recv_msg: *mut nng_msg = null_mut(...
posix_alloc.c:26:19 #2 0x5614ca0f3ca9 in nni_chunk_grow /home/runner/work/nng/nng/src/core/message.c:149:17 #3 0x5614ca0f34bb in nni_msg_alloc /home/runner/work/nng/nng/src/core/message.c:388:8 #4 0x5614ca0d036c in nng_msg_alloc /home/runner/work/nng/nng/src/nng.c:...
nni_msg *pingmsg; };// A mqtt_sock_s is our per-socket protocol private structure. @@ -298,6 +301,20 @@ mqtt_pipe_init(void *arg, nni_pipe *pipe, void *s) p->pipe = pipe; p->mqtt_sock = s; p->rid = 0;p->pingcnt = 0; ...
api: Remove the NNG_FLAG_ALLOC This flag failed to provide real zero copy that it was intended for, and it also involved extra allocations. Further, the API for it was brittle and error prone. Modern code should just work directly with nng_msg structures....
int rc = zmq_msg_send (&message, _pub, 0); zmq_msg_close (&message); unique_ptr<unsigned char> msgp(new unsigned char[str.length() + 1]); if(msgp) { memcpy (msgp.get(), str.data(), str.size()); rc = nng_send(_pub, msgp.get(), str.length(), 0); } return rc; }...