diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2023-07-15 12:45:13 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2023-07-15 12:45:13 +0200 |
| commit | a37251135ec3c91b5fb7312d30533111f94263e1 (patch) | |
| tree | b90363977ca2715259f81213a2a969e04c4476e3 /src/publisher.c | |
| parent | 97e167da1bd01570562913d6e496241f6cdb246e (diff) | |
Minor changes
Diffstat (limited to 'src/publisher.c')
| -rw-r--r-- | src/publisher.c | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/src/publisher.c b/src/publisher.c index 1416738..0068a56 100644 --- a/src/publisher.c +++ b/src/publisher.c @@ -12,18 +12,32 @@ // Global: char *__logdir; int __loginterval; +int __port; + +void publish(char *filepath, char* client, int interval); int main (int argc, char *argv []) { - if(argc != 3){ - printf("Usage: %s <abslogdir> <loginterval>",argv[0]); + if(argc != 4){ + printf("Usage: %s <abslogdir> <loginterval> <port>",argv[0]); exit(1); } //----- Init global variables __logdir=argv[1]; __loginterval=atoi(argv[2]); + __port=atoi(argv[3]); + //----- Prepare our context and publisher + void *context = zmq_ctx_new (); + void *publisher = zmq_socket (context, ZMQ_PUB); + char bindto[30]; + sprintf(bindto,"tcp://*:%d",__port); + int rc = zmq_bind (publisher, bindto); + if(rc!=0){ + printf("Failed to bind zmq on %s\n",bindto); + exit(1); + } //----- Start publisher DIR *dr = opendir(__logdir); @@ -46,7 +60,7 @@ int main (int argc, char *argv []) } // Send current one if(FILE_EXISTS(logfile)){ - printf("Sending....\n"); + publish(logfile,client,interval); } } } @@ -54,20 +68,26 @@ int main (int argc, char *argv []) closedir(dr); + zmq_close (publisher); + zmq_ctx_destroy (context); return 0; - // 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); + // // 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); + // // 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; +} + +void publish(char *filepath, char* client, int interval){ + }
\ No newline at end of file |
