responder

utility function for unit tests/examples

version(unittest)
void
responder
(
in string uri
,
in int timeoutMs
)

Examples

Example: push/pull over TCP

import core.thread: Thread, msecs;

auto pull = NanoSocket(NanoSocket.Protocol.pull, BindTo("tcp://localhost:13248"));
auto push = NanoSocket(NanoSocket.Protocol.push, ConnectTo("tcp://localhost:13248"));

enum numTimes = 10;

foreach(i; 0 .. numTimes)
    push.send("foo");

Thread.sleep(50.msecs);

foreach(i; 0 .. numTimes)
    pull.receive(No.blocking).shouldEqual("foo");

Example: push/pull over IPC

auto pull = NanoSocket(NanoSocket.Protocol.pull, BindTo("ipc://nanomsg_ipc_push_pull_test"));
auto push = NanoSocket(NanoSocket.Protocol.push, ConnectTo("ipc://nanomsg_ipc_push_pull_test"));

enum numTimes = 5;

foreach(i; 0 .. numTimes)
    push.send("foo");

foreach(i; 0 .. numTimes)
    pull.receive(No.blocking).shouldEqual("foo");

Meta