25 lines
632 B
C
25 lines
632 B
C
#include "zhelpers.h"
|
|
|
|
int main(void)
|
|
{
|
|
void *context = zmq_init(1);
|
|
void *publisher = zmq_socket(context, ZMQ_PUB);
|
|
zmq_bind(publisher, "tcp://*:5556");
|
|
zmq_bind(publisher, "ipc://weather.ipc");
|
|
|
|
srandom((unsigned) time (NULL));
|
|
while (1) {
|
|
int zipcode, temperature, relhumidity;
|
|
zipcode = randof(100000);
|
|
temperature = randof(215) - 80;
|
|
relhumidity = randof(50) + 10;
|
|
|
|
char update[20];
|
|
sprintf(update, "%05d %d %d", zipcode, temperature, relhumidity);
|
|
s_send(publisher, update);
|
|
}
|
|
zmq_close(publisher);
|
|
zmq_term(context);
|
|
return 0;
|
|
}
|