-
Notifications
You must be signed in to change notification settings - Fork 0
/
exptx.c
38 lines (29 loc) · 873 Bytes
/
exptx.c
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
33
34
35
36
37
38
#define _XOPEN_SOURCE
#include "zmq.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <assert.h>
#define BUFLEN 256
#define STRLEN 16
//#define ZMQTALKURL "tcp://138.201.156.239:5567"
#define ZMQTALKURL "tcp://*:5555"
int main(int argc, char *argv[])
{
char pbuffer[BUFLEN];
void *context = zmq_ctx_new();
void *publisher = zmq_socket(context, ZMQ_PUB);
int rc = zmq_bind(publisher, ZMQTALKURL);
printf("Established talk context and socket with %s status\n", rc == 0 ? "OK" : "NOT OK");
while (!false) // Replace false with close down signal
{
strcpy(pbuffer, "SKEW_TEST");
printf("Sent \"%s\"\n", pbuffer);
int size = zmq_send(publisher, pbuffer, strlen(pbuffer), 0);
assert(size == strlen(pbuffer));
sleep(1);
}
return 0;
}