Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8671479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:57:38+00:00 2026-06-12T18:57:38+00:00

The socket_t::send function examples returns a bool to indicate if the message was sent

  • 0

The socket_t::send function examples returns a bool to indicate if the message was sent successfully but I have never seen any sample code that checks this return value.

According to the 0MQ C++ API C errors are converted to exceptions:

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

Is it necessary to check the return value of send? Is there any case where the the send function would return false but not throw an exception?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:57:39+00:00Added an answer on June 12, 2026 at 6:57 pm

    From the source code:

    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 ();
    }
    

    So the answer is there – send will return false if zmq_send sets the error to EAGAIN. To understand when that could happen, read the documentation for zmq_socket and zmq_setsockopt.

    You should check the return value if the socket you are using might raise EAGAIN, and you want to handle this condition. You can handle it, for example, by queuing the message and trying again later.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with socket send (or write) function on android. There is
All examples i've seen were doing a query first and then send to client
I'm trying to send a String[] over an open socket connection but it's doesn't
I have been programming in C++ for a while but I am a beginner
I'm working with asyn sockets now. I have a callback function 'onDataReceived', which is
I can send/receive data over sockets using a char array but can't figure out
Since Javascript does not have any functionality by itself to communicate over raw sockets
I have a problem concerning boost asio libraries. I successfully tried to create a
Hi guys i have an issue currently when using a Socket to send data.
I'm interested in the behavior of send function when using a blocking socket. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.