Networking Reference
In-Depth Information
• The lags parameter is either ZMQ_DONTWAIT or ZMQ_SNDMORE . ZMQ_DONTWAIT
indicates that the message should be sent asynchronously. ZMQ_SNDMORE
indicates that the message is a multipart message and the rest of the parts
of the message are on the way.
After sending the message, the client waits to receive a response. This is done by
using zmq_msg_recv(3) .
zmq_msg_recv(&reply, request, 0);
printf("Received: hello - %d\n", count);
zmq_msg_close(&reply);
zmq_msg_recv(3) receives a part of the message from the socket, as specified in the
socket parameter, and stores the reply in the message parameter.
int zmq_msg_recv (zmq_msg_t *msg, void *socket, int flags)
zmq_msg_recv takes three parameters, namely, message, socket, and lags.
• The previously received message (if any) is nullified
• The lags parameter could be ZMQ_DONTWAIT , which indicates that the
operation should be done asynchronously
Handling strings in C
Every programming language has a different approach to handling strings. Erlang does
not even have strings. In the C programming language, strings are null-terminated.
Strings in C are basically character arrays where \0 states the end of the string. String
manipulation errors are common and the result of many security vulnerabilities.
According to Miller and others (1995), 65 percent of Unix failures are due to string
manipulation errors such as null-terminated byte and buffer overflow; therefore,
handling strings in C should be done carefully.
When you send a message with ZeroMQ, it is your responsibility to format it safely,
so that other applications can read it. ZeroMQ only knows the size of the message.
That's about it.
It is a common way to use different programming languages in an application. An
application written in a programming language that does not add a null-byte at the
end of strings and C application code needs to communicate properly otherwise you
will get strange results.
 
Search MirCeyron ::




Custom Search