From 6ef5e30b868474c04746d0eadd4b13526947062a Mon Sep 17 00:00:00 2001
From: gdamore
int nng_send(nng_socket s, void *data, size_t size, int flags);
int nng_sendmsg(nng_socket s, nng_msg *msg, int flags);
-void nng_send_aio(nng_socket s, nng_aio *aio);
+void nng_socket_send(nng_socket s, nng_aio *aio);
-These functions (nng_send, nng_sendmsg, and nng_send_aio) send
+
These functions (nng_send, nng_sendmsg, and nng_socket_send) send
messages over the socket s. The differences in their behaviors are as follows.
@@ -1319,8 +1319,8 @@ cannot accept more data for sending. In such a case, it will return nng_send, as it gives access to the message structure and eliminates both
a data copy and allocation.
The nng_send_aio function sends a message asynchronously, using the nng_aio aio, over the socket s.
+
The nng_socket_send function sends a message asynchronously, using the nng_aio aio, over the socket s.
The message to send must have been set on aio using the nng_aio_set_msg function.
If the operation completes successfully, then the socket will have disposed of the message.
However, if it fails, then callback of aio should arrange for a final disposition of the message.
@@ -1339,9 +1339,9 @@ this function instead of These functions ( These functions (
@@ -1376,8 +1376,8 @@ has no messages available to receive. In such a case, it will return The The
@@ -1492,7 +1492,7 @@ when possible. This example demonstrates the use of This example demonstrates the use of This example demonstrates the use of This example demonstrates the use of The The flags can contain the value The It is now required for applications to initialize the library explicitly before using it.
This is done using the The The following functions have been renamed as described by the following table.
+The old names are available by defining the macro The following macro aliases are removed, unless The Modern code should use one of Modern code should use one of When an operation fails with nng_sendReceiving Messages
-int nng_recv(nng_socket s, void *data, size_t *sizep, int flags);
int nng_recvmsg(nng_socket s, nng_msg **msgp, int flags);
-void nng_recv_aio(nng_socket s, nng_aio *aio);
+void nng_socket_recv(nng_socket s, nng_aio *aio);
nng_recv, nng_recvmsg, and nng_recv_aio) receive
+nng_recv, nng_recvmsg, and nng_socket_recv) receive
messages over the socket s. The differences in their behaviors are as follows.nng_recv, as it gives access to the message structure and eliminates both
a data copy and allocation.nng_recv_aio
-nng_send_aio function receives a message asynchronously, using the nng_aio aio, over the socket s.
+nng_socket_recv
+nng_socket_send function receives a message asynchronously, using the nng_aio aio, over the socket s.
On success, the received message can be retrieved from the aio using the nng_aio_get_msg function.nng_socket s = NNG_SOCKET_INITIALIZER;
Example 2: Publishing a Timestamp
-nng_aio, nng_send_aio, and nng_sleep_aio to
+nng_aio, nng_socket_send, and nng_sleep_aio to
build a service that publishes a timestamp at one second intervals. Error handling is elided for the
sake of clarity.#include <stdlib.h>
@@ -1522,7 +1522,7 @@ void callback(void *arg) {
now = nng_clock();
nng_msg_append(msg, &now, sizeof (now)); // note: native endian
nng_aio_set_msg(state->aio, msg);
- nng_send_aio(state->s, state->aio);
+ nng_socket_send(state->s, state->aio);
} else {
state->sleeping = true;
nng_sleep_aio(1000, state->aio); // 1000 ms == 1 second
@@ -1543,7 +1543,7 @@ int main(int argc, char **argv) {
}
Example 3: Watching a Periodic Timestamp
-nng_aio, nng_recv_aio, to build a client to
+nng_aio, nng_socket_recv, to build a client to
watch for messages received from the service created in Example 2.
Error handling is elided for the sake of clarity.#include <stdlib.h>
@@ -1572,7 +1572,7 @@ void callback(void *arg) {
printf("Timestamp is %lu\n", (unsigned long)now);
nng_msg_free(msg);
nng_aio_set_msg(state->aio, NULL);
- nng_recv_aio(state->s, state->aio);
+ nng_socket_recv(state->s, state->aio);
}
int main(int argc, char **argv) {
@@ -1582,7 +1582,7 @@ int main(int argc, char **argv) {
nng_sub0_open(&state.s);
nng_sub0_socket_subscribe(state.s, NULL, 0); // subscribe to everything
nng_dial(state.s, url, NULL, 0);
- nng_recv_aio(state.s, state.aio); // kick it off right away
+ nng_socket_recv(state.s, state.aio); // kick it off right away
for(;;) {
nng_msleep(0x7FFFFFFF); // infinite, could use pause or sigsuspend
}
@@ -1788,7 +1788,7 @@ Additionally, some protocols may not support receiving at all or may require oth
nng_ctx_recvmsg function receives a message and stores a pointer to the nng_msg for that message in msgp.NNG_FLAG_NONBLOCK, indicating that the function should not wait if the socket
has no messages available to receive. In such a case, it will return NNG_EAGAIN.nng_recv_aio
+nng_socket_recv
nng_ctx_send function receives a message asynchronously, using the nng_aio aio, over the context ctx.
On success, the received message can be retrieved from the aio using the nng_aio_get_msg function.nng_init function.Renamed Functions
-nng_close function has been renamed to nng_socket_close to make it clearer that
-the object being closed is a socket. A compatible nng_close macro is available by defining NNG1_TRANSITION
-in your compilation environment.NNG1_TRANSITION in your compilation environment.
+
+Old Name New Name
+nng_closenng_socket_close
+nng_recv_aionng_socket_recv
+nng_send_aionng_socket_sendRemoved Protocol Aliases
NNG1_TRANSITION is defined in your compilation environment.
@@ -6773,7 +6778,7 @@ Please remove
#include references to protocol headers as we anticip
NNG_FLAG_ALLOC flag that allowed a zero copy semantic with nng_send and nng_recv is removed.
This was implemented mostly to aid legacy nanomsg applications, and it was both error prone and still a bit
suboptimal in terms of performance.nng_sendmsg, nng_recvmsg, nng_send_aio, or nng_recv_aio to get the maximum performance benefit.
+nng_sendmsg, nng_recvmsg, nng_socket_send, or nng_socket_recv to get the maximum performance benefit.
Working directly with nng_msg structures gives more control, reduces copies, and reduces allocation activity.New AIO Error Code NNG_ESTOPPED
NNG_ESTOPPED, it means that the associated [nni_aio] object has
@@ -7364,7 +7369,6 @@ named pipes, 1
nng_push0_open_raw, 1
nng_random, 1
nng_recv, 1
-nng_recv_aio, 1
nng_recvmsg, 1
nng_rep0_open, 1
nng_rep0_open_raw, 1
@@ -7373,7 +7377,6 @@ named pipes, 1
nng_respondent0_open, 1
nng_respondent0_open_raw, 1
nng_send, 1
-nng_send_aio, 1
nng_sendmsg, 1
nng_sleep_aio, 1
nng_socket, 1
@@ -7386,6 +7389,8 @@ named pipes, 1
nng_socket_proto_id, 1
nng_socket_proto_name, 1
nng_socket_raw, 1
+nng_socket_recv, 1
+nng_socket_send, 1
nng_stat, 1
nng_stat_bool, 1
NNG_STAT_BOOLEAN, 1
--
cgit v1.2.3-70-g09d2