Networking Reference
In-Depth Information
zmq_msg_t message;
zmq_msg_init_size(&message, s_len);
memcpy(zmq_msg_data(&message), str, s_len);
zmq_msg_send(&message, publisher, 0);
zmq_msg_close(&message);
sleep(1);
}
zmq_close(publisher);
zmq_ctx_destroy(context);
return 0;
}
And the subscriber that runs slower:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <time.h>
#include "zmq.h"
#define DELAY 4
int main (int argc, char const *argv[]) {
void* context = zmq_ctx_new();
void* subscriber = zmq_socket(context, ZMQ_SUB);
printf("Getting data...\n");
int conn = zmq_connect(subscriber, "tcp://localhost:4040");
conn = zmq_setsockopt(subscriber, ZMQ_SUBSCRIBE, 0, 0);
int i ;
for(i = 0; i < 10; i++) {
time_t current_time = time(NULL) % 86400;
zmq_msg_t reply;
zmq_msg_init(&reply);
zmq_msg_recv(&reply, subscriber, 0);
 
Search MirCeyron ::




Custom Search