Socket.tryReceive

Receives a message part.

_receive blocks until the request can be satisfied. tryReceive performs the operation in non-blocking mode, and returns a bool value that signifies whether a message was received.

  1. Tuple!(size_t, bool) tryReceive(ubyte[] data)
  2. Tuple!(size_t, bool) tryReceive(Message msg)
    struct Socket
    @safe
    Tuple!(size_t, bool)
    tryReceive
    ()
  3. this(SocketType type)
  4. this(Context context, SocketType type)

Throws

ZmqException if $(ZMQ) reports an error.

Corresponds to

$(ZMQREF zmq_msg_recv()) (with the ZMQ_DONTWAIT flag, in the case of tryReceive).

Examples

// Sender
auto snd = Socket(SocketType.req);
snd.connect("ipc://zmqd_msg_receive_example");
snd.send("Hello World!");

// Receiver
import std.string: representation;
auto rcv = Socket(SocketType.rep);
rcv.bind("ipc://zmqd_msg_receive_example");
auto msg = Message();
rcv.receive(msg);
assert (msg.data.asString() == "Hello World!");

Meta