mirror of
https://gitlab.com/manzerbredes/ina260-zmq-publisher.git
synced 2025-04-07 04:16:26 +02:00
Minor changes
This commit is contained in:
parent
2e02fd6b93
commit
6172ad7092
7 changed files with 22 additions and 4 deletions
4
Makefile
4
Makefile
|
@ -1,13 +1,17 @@
|
||||||
|
PUBLISHER_PORT=5556
|
||||||
CC="gcc"
|
CC="gcc"
|
||||||
|
CFLAGS=
|
||||||
|
|
||||||
all: publisher client
|
all: publisher client
|
||||||
|
|
||||||
publisher:
|
publisher:
|
||||||
echo "Building publisher..."
|
echo "Building publisher..."
|
||||||
|
CFLAGS+=-DPUBLISHER_PORT=$(PUBLISHER_PORT) \
|
||||||
$(MAKE) -C src/publisher/ CC=$(CC) OUT=$(PWD)
|
$(MAKE) -C src/publisher/ CC=$(CC) OUT=$(PWD)
|
||||||
|
|
||||||
client:
|
client:
|
||||||
echo "Building client..."
|
echo "Building client..."
|
||||||
|
CFLAGS+=-DPUBLISHER_PORT=$(PUBLISHER_PORT) \
|
||||||
$(MAKE) -C src/client/ CC=$(CC) OUT=$(PWD)
|
$(MAKE) -C src/client/ CC=$(CC) OUT=$(PWD)
|
||||||
|
|
||||||
|
|
||||||
|
|
BIN
client
BIN
client
Binary file not shown.
BIN
publisher
BIN
publisher
Binary file not shown.
|
@ -1,5 +1,5 @@
|
||||||
EXEC=client
|
EXEC=client
|
||||||
CFLAGS=-lzmq
|
CFLAGS+=-lzmq
|
||||||
|
|
||||||
all: main.c
|
all: main.c
|
||||||
$(CC) $^ -o $(OUT)/$(EXEC) $(CFLAGS)
|
$(CC) $^ -o $(OUT)/$(EXEC) $(CFLAGS)
|
||||||
|
|
|
@ -6,13 +6,20 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#define STR(symbol) #symbol
|
||||||
|
#define STRINGIFY(symbol) STR(symbol)
|
||||||
|
|
||||||
|
#ifndef PUBLISHER_PORT
|
||||||
|
#error PUBLISHER_PORT macro undefined
|
||||||
|
#endif
|
||||||
|
|
||||||
int main (int argc, char *argv [])
|
int main (int argc, char *argv [])
|
||||||
{
|
{
|
||||||
// Socket to talk to server
|
// Socket to talk to server
|
||||||
printf ("Collecting updates from weather server...\n");
|
printf ("Collecting updates from weather server...\n");
|
||||||
void *context = zmq_ctx_new ();
|
void *context = zmq_ctx_new ();
|
||||||
void *subscriber = zmq_socket (context, ZMQ_SUB);
|
void *subscriber = zmq_socket (context, ZMQ_SUB);
|
||||||
int rc = zmq_connect (subscriber, "tcp://localhost:5556");
|
int rc = zmq_connect (subscriber, "tcp://localhost:"STRINGIFY(PUBLISHER_PORT));
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
|
|
||||||
// Subscribe to zipcode, default is NYC, 10001
|
// Subscribe to zipcode, default is NYC, 10001
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
EXEC=publisher
|
EXEC=publisher
|
||||||
CFLAGS=-lzmq
|
CFLAGS+=-lzmq
|
||||||
|
|
||||||
all: main.c
|
all: main.c
|
||||||
$(CC) $^ -o $(OUT)/$(EXEC) $(CFLAGS)
|
$(CC) $^ -o $(OUT)/$(EXEC) $(CFLAGS)
|
||||||
|
|
|
@ -6,12 +6,19 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <time.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)
|
int main (void)
|
||||||
{
|
{
|
||||||
// Prepare our context and publisher
|
// Prepare our context and publisher
|
||||||
void *context = zmq_ctx_new ();
|
void *context = zmq_ctx_new ();
|
||||||
void *publisher = zmq_socket (context, ZMQ_PUB);
|
void *publisher = zmq_socket (context, ZMQ_PUB);
|
||||||
int rc = zmq_bind (publisher, "tcp://*:5556");
|
int rc = zmq_bind (publisher, "tcp://*:"STRINGIFY(PUBLISHER_PORT));
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
|
|
||||||
// Initialize random number generator
|
// Initialize random number generator
|
||||||
|
|
Loading…
Add table
Reference in a new issue