blob: 817d79f13db0b1d0398d79ea2ab11f0c6b5170b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// Weather update server
// Binds PUB socket to tcp://*:5556
// Publishes random weather updates
#include <zmq.h>
#include <assert.h>
#include <time.h>
#define STR(symbol) #symbol
#define STRINGIFY(symbol) STR(symbol)
#ifndef PUBLISHER_PORT
#error PUBLISHER_PORT macro undefined
#endif
int main (void)
{
// Prepare our context and publisher
void *context = zmq_ctx_new ();
void *publisher = zmq_socket (context, ZMQ_PUB);
int rc = zmq_bind (publisher, "tcp://*:"STRINGIFY(PUBLISHER_PORT));
assert (rc == 0);
// Initialize random number generator
while (1) {
zmq_send (publisher, "Hello World", 5, 0);
printf("AA\n");
}
zmq_close (publisher);
zmq_ctx_destroy (context);
return 0;
}
|