responder

utility function for unit tests/examples

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

Examples

Example: push/pull over TCP

1 import core.thread: Thread, msecs;
2 
3 auto pull = NanoSocket(NanoSocket.Protocol.pull, BindTo("tcp://localhost:13248"));
4 auto push = NanoSocket(NanoSocket.Protocol.push, ConnectTo("tcp://localhost:13248"));
5 
6 enum numTimes = 10;
7 
8 foreach(i; 0 .. numTimes)
9     push.send("foo");
10 
11 Thread.sleep(50.msecs);
12 
13 foreach(i; 0 .. numTimes)
14     pull.receive(No.blocking).shouldEqual("foo");

Example: push/pull over IPC

1 auto pull = NanoSocket(NanoSocket.Protocol.pull, BindTo("ipc://nanomsg_ipc_push_pull_test"));
2 auto push = NanoSocket(NanoSocket.Protocol.push, ConnectTo("ipc://nanomsg_ipc_push_pull_test"));
3 
4 enum numTimes = 5;
5 
6 foreach(i; 0 .. numTimes)
7     push.send("foo");
8 
9 foreach(i; 0 .. numTimes)
10     pull.receive(No.blocking).shouldEqual("foo");

Meta