Electroneum
Loading...
Searching...
No Matches
zmq.h File Reference
#include <memory>
#include <string>
#include <system_error>
#include <zmq.h>
#include "common/expect.h"
#include "span.h"
Include dependency graph for zmq.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  net::zmq::terminate
 Calls zmq_term. More...
struct  net::zmq::close
 Calls zmq_close. More...

Namespaces

namespace  net
namespace  net::zmq

Macros

#define ELECTRONEUM_ZMQ_CHECK(...)
 If the expression is less than 0, return the current ZMQ error code.
#define ELECTRONEUM_LOG_ZMQ_ERROR(...)
 Print a message followed by the current ZMQ error message.
#define ELECTRONEUM_ZMQ_THROW(msg)
 Throw an exception with a custom msg, current ZMQ error code, filename, and line number.

Typedefs

using net::zmq::context = std::unique_ptr<void, terminate>
 Unique ZMQ context handle, calls zmq_term on destruction.
using net::zmq::socket = std::unique_ptr<void, close>
 Unique ZMQ socket handle, calls zmq_close on destruction.

Functions

const std::error_category & net::zmq::error_category () noexcept
std::error_code net::zmq::make_error_code (int code) noexcept
std::error_code net::zmq::get_error_code () noexcept
expect< std::string > net::zmq::receive (void *const socket, const int flags)
expect< void > net::zmq::send (const epee::span< const std::uint8_t > payload, void *const socket, const int flags) noexcept

Macro Definition Documentation

◆ ELECTRONEUM_LOG_ZMQ_ERROR

#define ELECTRONEUM_LOG_ZMQ_ERROR ( ...)
Value:
do \
{ \
MERROR( __VA_ARGS__ << ": " << ::net::zmq::get_error_code().message()); \
} while (0)
std::string message("Message requiring signing")
std::error_code get_error_code() noexcept
Definition zmq.h:70

Print a message followed by the current ZMQ error message.

Definition at line 46 of file zmq.h.

46#define ELECTRONEUM_LOG_ZMQ_ERROR(...) \
47 do \
48 { \
49 MERROR( __VA_ARGS__ << ": " << ::net::zmq::get_error_code().message()); \
50 } while (0)

◆ ELECTRONEUM_ZMQ_CHECK

#define ELECTRONEUM_ZMQ_CHECK ( ...)
Value:
do \
{ \
if (( __VA_ARGS__ ) < 0) \
} while (0)

If the expression is less than 0, return the current ZMQ error code.

Definition at line 38 of file zmq.h.

38#define ELECTRONEUM_ZMQ_CHECK(...) \
39 do \
40 { \
41 if (( __VA_ARGS__ ) < 0) \
42 return {::net::zmq::get_error_code()}; \
43 } while (0)

◆ ELECTRONEUM_ZMQ_THROW

#define ELECTRONEUM_ZMQ_THROW ( msg)
Value:
#define ELECTRONEUM_THROW(code, msg)
Definition expect.h:66

Throw an exception with a custom msg, current ZMQ error code, filename, and line number.

Definition at line 53 of file zmq.h.

53#define ELECTRONEUM_ZMQ_THROW(msg) \
54 ELECTRONEUM_THROW( ::net::zmq::get_error_code(), msg )