mirror of
https://gitlab.com/manzerbredes/ina260-zmq-publisher.git
synced 2025-04-19 04:09:45 +00:00
Minor changes
This commit is contained in:
parent
e0fdde7cd0
commit
33c5443794
4 changed files with 37 additions and 6 deletions
|
@ -2,9 +2,17 @@
|
|||
#include <assert.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include "utils.h"
|
||||
|
||||
unsigned char __stop=0;
|
||||
void sighandler(int signo){
|
||||
if (signo == SIGINT){
|
||||
printf("Stopping...\n");
|
||||
__stop=1;
|
||||
}
|
||||
}
|
||||
|
||||
int main (int argc, char *argv [])
|
||||
{
|
||||
if(argc != 3){
|
||||
|
@ -18,6 +26,7 @@ int main (int argc, char *argv [])
|
|||
|
||||
//----- Various inits
|
||||
mkdirp(cdatadir);
|
||||
signal(SIGINT,sighandler);
|
||||
|
||||
//----- Init ZMQ
|
||||
void *context = zmq_ctx_new ();
|
||||
|
@ -35,8 +44,10 @@ int main (int argc, char *argv [])
|
|||
//----- Listen
|
||||
char buffer[ZMQ_MSG_SIZE];
|
||||
int size;
|
||||
while(1){
|
||||
while(!__stop){
|
||||
size=zmq_recv (subscriber, buffer, ZMQ_MSG_SIZE-1, 0);
|
||||
if(size<=0)
|
||||
continue;
|
||||
buffer[size < ZMQ_MSG_SIZE ? size : ZMQ_MSG_SIZE - 1] = '\0';
|
||||
//----- Read buffer
|
||||
char *token = strtok(buffer, "\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue