Is it necessary to check the return value of a send in 0MQ using C ++?

The socket_t :: send function examples return bool to indicate whether the message was sent successfully, but I have never seen an example code that checks for this return value.

According to the 0MQ C ++ API , C errors are thrown into exceptions:

All errors indicated by the basic functions of the ØMQ C library are automatically converted to exceptions due to the binding of the C ++ language. The zmq :: error_t class is derived from the std :: exception class and uses the zmq_strerror () function to convert the error code to a human-readable string.

Do I need to check the return value of the submission? Is there a case where the send function returns false but does not throw an exception?

+5
source share
1

:

inline bool send (message_t &msg_, int flags_ = 0)
{
    int rc = zmq_send (ptr, &msg_, flags_);
    if (rc == 0)
        return true;
    if (rc == -1 && zmq_errno () == EAGAIN)
        return false;
    throw error_t ();
}

, - send false, zmq_send EAGAIN. , , zmq_socket zmq_setsockopt.

, , , EAGAIN, . , , .

+3

All Articles