box-o-sand/zeromq/taskwork.c

28 lines
566 B
C

#include "zhelpers.h"
int main(void)
{
void *context = zmq_init(1);
void *receiver = zmq_socket(context, ZMQ_PULL);
zmq_connect(receiver, "tcp://localhost:5557");
void *sender = zmq_socket(context, ZMQ_PUSH);
zmq_connect(sender, "tcp://localhost:5558");
while (1) {
char *string = s_recv(receiver);
fflush(stdout);
printf("%s.", string);
s_sleep(atoi(string));
free(string);
s_send(sender, "");
}
zmq_close(receiver);
zmq_close(sender);
zmq_term(context);
return 0;
}