my
$MAX_MESSAGES
= 1_000;
my
$port
= Test::TCP::empty_port();
my
$server
= Proc::Guard->new(
code
=>
sub
{
my
$ctxt
= zmq_init();
my
$sender
= zmq_socket(
$ctxt
, ZMQ_PUSH);
zmq_bind(
$sender
,
"tcp://*:$port"
);
sleep
3;
my
$ident
=0;
while
(
$ident
<
$MAX_MESSAGES
) {
note
"sending "
.
$ident
++,
"\n"
;
zmq_sendmsg(
$sender
, zmq_msg_init_data(
$ident
));
}
note
"Done sending"
;
sleep
(1);
});
{
my
$ctxt
= zmq_init();
my
$receiver
= zmq_socket(
$ctxt
, ZMQ_PULL);
for
my
$expected
(1..
$MAX_MESSAGES
) {
my
$msg
= zmq_recvmsg(
$receiver
);
is zmq_msg_data(
$msg
),
$expected
;
}
}
undef
$server
;
done_testing;