cis_config: /root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h Source File

cis_config

ZMQComm.h
1
2 #ifndef CISZMQCOMM_H_
3 #define CISZMQCOMM_H_
4
5 #include <CommBase.h>
6 #include "comm_header.h"
7
8 #ifdef ZMQINSTALLED
9 #include <czmq.h>
10 #endif
11
12 #ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
13 extern "C" {
14 #endif
15
16 #ifdef ZMQINSTALLED
17
18 static unsigned _zmq_rand_seeded = 0;
19 static unsigned _last_port_set = 0;
20 static unsigned _cisSocketsCreated = 0;
21 static int _last_port = 49152;
22 /* static double _wait_send_t = 0; // 0.0001; */
23 static char _reply_msg[100] = "CIS_REPLY";
24 static char _purge_msg[100] = "CIS_PURGE";
25 static int _zmq_sleeptime = 10000;
26
30 typedef struct zmq_reply_t {
31 int nsockets;
32 zsock_t **sockets;
33 char **addresses;
34 int n_msg;
35 int n_rep;
36 } zmq_reply_t;
37
38
39 // Forward declarations
40 static inline
41 int zmq_comm_nmsg(const comm_t x);
42 static inline
43 int zmq_comm_recv(const comm_t x, char **data, const size_t len,
44 const int allow_realloc);
45
46
52 static inline
53 int free_zmq_reply(zmq_reply_t *x) {
54 int i = 0;
55 if (x != NULL) {
56 if (x->sockets != NULL) {
57 for (i = 0; i < x->nsockets; i++) {
58 if (x->sockets[i] != NULL) {
59 zsock_destroy(&(x->sockets[i]));
60 x->sockets[i] = NULL;
61 }
62 }
63 free(x->sockets);
64 }
65 if (x->addresses != NULL) {
66 for (i = 0; i < x->nsockets; i++) {
67 if (x->addresses[i] != NULL) {
68 free(x->addresses[i]);
69 x->addresses[i] = NULL;
70 }
71 }
72 free(x->addresses);
73 }
74 x->nsockets = 0;
75 }
76 return 0;
77 }
78
84 static inline
85 int init_zmq_reply(comm_t *comm) {
86 zmq_reply_t *zrep = (zmq_reply_t*)malloc(sizeof(zmq_reply_t));
87 if (zrep == NULL) {
88 cislog_error("init_zmq_reply(%s): Failed to malloc reply.", comm->name);
89 return -1;
90 }
91 zrep->nsockets = 0;
92 zrep->sockets = NULL;
93 zrep->addresses = NULL;
94 zrep->n_msg = 0;
95 zrep->n_rep = 0;
96 comm->reply = (void*)zrep;
97 return 0;
98 };
99
106 static inline
107 int find_reply_socket(const comm_t *comm, const char *address) {
108 int ret = -1;
109 // Get reply
110 zmq_reply_t *zrep = (zmq_reply_t*)(comm->reply);
111 if (zrep == NULL) {
112 cislog_error("find_reply_socket(%s): Reply structure not initialized.", comm->name);
113 return -2;
114 }
115 int i = 0;
116 for (i = 0; i < zrep->nsockets; i++) {
117 if (strcmp(zrep->addresses[i], address) == 0) {
118 ret = i;
119 break;
120 }
121 }
122 return ret;
123 };
124
130 static inline
131 int do_reply_send(const comm_t *comm) {
132 // Get reply
133 zmq_reply_t *zrep = (zmq_reply_t*)(comm->reply);
134 if (zrep == NULL) {
135 cislog_error("do_reply_send(%s): Reply structure not initialized.", comm->name);
136 return -1;
137 }
138 zrep->n_msg++;
139 zsock_t *s = (zsock_t*)(zrep->sockets[0]);
140 if (s == NULL) {
141 cislog_error("do_reply_send(%s): Socket is NULL.", comm->name);
142 return -1;
143 }
144 // Poll
145 cislog_debug("do_reply_send(%s): address=%s, begin", comm->name,
146 zrep->addresses[0]);
147 #if defined(__cplusplus) && defined(_WIN32)
148 // TODO: There seems to be an error in the poller when using it in C++
149 #else
150 zpoller_t *poller = zpoller_new(s, NULL);
151 if (!(poller)) {
152 cislog_error("do_reply_send(%s): Could not create poller", comm->name);
153 return -1;
154 }
155 assert(poller);
156 cislog_debug("do_reply_send(%s): waiting on poller...", comm->name);
157 void *p = zpoller_wait(poller, -1);
158 //void *p = zpoller_wait(poller, 1000);
159 cislog_debug("do_reply_send(%s): poller returned", comm->name);
160 zpoller_destroy(&poller);
161 if (p == NULL) {
162 if (zpoller_terminated(poller)) {
163 cislog_error("do_reply_send(%s): Poller interrupted", comm->name);
164 } else if (zpoller_expired(poller)) {
165 cislog_error("do_reply_send(%s): Poller expired", comm->name);
166 } else {
167 cislog_error("do_reply_send(%s): Poller failed", comm->name);
168 }
169 return -1;
170 }
171 #endif
172 // Receive
173 zframe_t *msg = zframe_recv(s);
174 if (msg == NULL) {
175 cislog_error("do_reply_send(%s): did not receive", comm->name);
176 return -1;
177 }
178 char *msg_data = (char*)zframe_data(msg);
179 // Check for EOF
180 int is_purge = 0;
181 if (strcmp(msg_data, CIS_MSG_EOF) == 0) {
182 cislog_debug("do_reply_send(%s): EOF received", comm->name);
183 zrep->n_msg = 0;
184 zrep->n_rep = 0;
185 return -2;
186 } else if (strcmp(msg_data, _purge_msg) == 0) {
187 is_purge = 1;
188 }
189 // Send
190 // zsock_set_linger(s, _zmq_sleeptime);
191 int ret = zframe_send(&msg, s, 0);
192 // Check for purge or EOF
193 if (ret < 0) {
194 cislog_error("do_reply_send(%s): Error sending reply frame.", comm->name);
195 zframe_destroy(&msg);
196 } else {
197 if (is_purge == 1) {
198 cislog_debug("do_reply_send(%s): PURGE received", comm->name);
199 zrep->n_msg = 0;
200 zrep->n_rep = 0;
201 ret = do_reply_send(comm);
202 } else {
203 zrep->n_rep++;
204 }
205 }
206 cislog_debug("do_reply_send(%s): address=%s, end", comm->name,
207 zrep->addresses[0]);
208 return ret;
209 };
210
218 static inline
219 int do_reply_recv(const comm_t *comm, const int isock, const char *msg) {
220 // Get reply
221 zmq_reply_t *zrep = (zmq_reply_t*)(comm->reply);
222 if (zrep == NULL) {
223 cislog_error("do_reply_recv(%s): Reply structure not initialized.", comm->name);
224 return -1;
225 }
226 zsock_t *s = (zsock_t*)(zrep->sockets[isock]);
227 if (s == NULL) {
228 cislog_error("do_reply_recv(%s): Socket is NULL.", comm->name);
229 return -1;
230 }
231 cislog_debug("do_reply_recv(%s): address=%s, begin", comm->name,
232 zrep->addresses[isock]);
233 zframe_t *msg_send = zframe_new(msg, strlen(msg));
234 if (msg_send == NULL) {
235 cislog_error("do_reply_recv(%s): Error creating frame.", comm->name);
236 return -1;
237 }
238 // Send
239 int ret = zframe_send(&msg_send, s, 0);
240 if (ret < 0) {
241 cislog_error("do_reply_recv(%s): Error sending confirmation.", comm->name);
242 zframe_destroy(&msg_send);
243 return -1;
244 }
245 if (strcmp(msg, CIS_MSG_EOF) == 0) {
246 zrep->n_msg = 0;
247 zrep->n_rep = 0;
248 zsock_set_linger(s, _zmq_sleeptime);
249 return -2;
250 }
251 // Receive
252 zframe_t *msg_recv = zframe_recv(s);
253 if (msg_recv == NULL) {
254 cislog_error("do_reply_recv(%s): did not receive", comm->name);
255 return -1;
256 }
257 zframe_destroy(&msg_recv);
258 zrep->n_rep++;
259 cislog_debug("do_reply_recv(%s): address=%s, end", comm->name,
260 zrep->addresses[isock]);
261 return 0;
262 };
263
269 static inline
270 char *set_reply_send(const comm_t *comm) {
271 char *out = NULL;
272 // Get reply
273 zmq_reply_t *zrep = (zmq_reply_t*)(comm->reply);
274 if (zrep == NULL) {
275 cislog_error("set_reply_send(%s): Reply structure not initialized.", comm->name);
276 return out;
277 }
278 // Create socket
279 if (zrep->nsockets == 0) {
280 zrep->sockets = (zsock_t**)malloc(sizeof(zsock_t*));
281 if (zrep->sockets == NULL) {
282 cislog_error("set_reply_send(%s): Error mallocing sockets.", comm->name);
283 return out;
284 }
285 zrep->nsockets = 1;
286 zrep->sockets[0] = zsock_new(ZMQ_REP);
287 zsock_set_linger(zrep->sockets[0], 0);
288 if (zrep->sockets[0] == NULL) {
289 cislog_error("set_reply_send(%s): Could not initialize empty socket.",
290 comm->name);
291 return out;
292 }
293 char protocol[50] = "tcp";
294 char host[50] = "localhost";
295 if (strcmp(host, "localhost") == 0)
296 strcpy(host, "127.0.0.1");
297 char address[100];
298 if (_last_port_set == 0) {
299 cislog_debug("model_index = %s", getenv("CIS_MODEL_INDEX"));
300 _last_port = 49152 + 1000 * atoi(getenv("CIS_MODEL_INDEX"));
301 _last_port_set = 1;
302 cislog_debug("_last_port = %d", _last_port);
303 }
304 sprintf(address, "%s://%s:*[%d-]", protocol, host, _last_port + 1);
305 int port = zsock_bind(zrep->sockets[0], "%s", address);
306 if (port == -1) {
307 cislog_error("check_reply_send(%s): Could not bind socket to address = %s",
308 comm->name, address);
309 return out;
310 }
311 _last_port = port;
312 sprintf(address, "%s://%s:%d", protocol, host, port);
313 zrep->addresses = (char**)malloc(sizeof(char*));
314 zrep->addresses[0] = (char*)malloc((strlen(address) + 1)*sizeof(char));
315 strcpy(zrep->addresses[0], address);
316 cislog_debug("check_reply_send(%s): New reply socket: %s", comm->name, address);
317 }
318 out = zrep->addresses[0];
319 return out;
320 };
321
327 static inline
328 int set_reply_recv(const comm_t *comm, const char* address) {
329 int out = -1;
330 // Get reply
331 zmq_reply_t *zrep = (zmq_reply_t*)(comm->reply);
332 if (zrep == NULL) {
333 cislog_error("set_reply_recv(%s): Reply structure not initialized.", comm->name);
334 return out;
335 }
336 // Match address and create if it dosn't exist
337 int isock = find_reply_socket(comm, address);
338 if (isock < 0) {
339 if (isock == -2) {
340 cislog_error("set_reply_recv(%s): Error locating socket.", comm->name);
341 return out;
342 }
343 // Realloc arrays
344 zrep->sockets = (zsock_t**)realloc(zrep->sockets,
345 sizeof(zsock_t*)*(zrep->nsockets + 1));
346 if (zrep->sockets == NULL) {
347 cislog_error("set_reply_recv(%s): Error reallocing sockets.", comm->name);
348 return out;
349 }
350 zrep->addresses = (char**)realloc(zrep->addresses,
351 sizeof(char*)*(zrep->nsockets + 1));
352 if (zrep->addresses == NULL) {
353 cislog_error("set_reply_recv(%s): Error reallocing addresses.", comm->name);
354 return out;
355 }
356 // Create new socket
357 isock = zrep->nsockets;
358 zrep->nsockets++;
359 zrep->sockets[isock] = zsock_new(ZMQ_REQ);
360 zsock_set_linger(zrep->sockets[isock], 0);
361 if (zrep->sockets[isock] == NULL) {
362 cislog_error("set_reply_recv(%s): Could not initialize empty socket.",
363 comm->name);
364 return out;
365 }
366 zrep->addresses[isock] = (char*)malloc(sizeof(char)*(strlen(address) + 1));
367 if (zrep->addresses[isock] == NULL) {
368 cislog_error("set_reply_recv(%s): Could not realloc new address.",
369 comm->name);
370 return out;
371 }
372 strcpy(zrep->addresses[isock], address);
373 int ret = zsock_connect(zrep->sockets[isock], "%s", address);
374 if (ret < 0) {
375 cislog_error("set_reply_recv(%s): Could not connect to socket.",
376 comm->name);
377 return out;
378 }
379 cislog_debug("set_reply_recv(%s): New recv socket: %s", comm->name, address);
380 }
381 return isock;
382 };
383
391 static inline
392 char* check_reply_send(const comm_t *comm, const char *data, const int len,
393 int *new_len) {
394 char *out = (char*)malloc(len + 1);
395 memcpy(out, data, len + 1);
396 new_len[0] = len;
397 return out;
398 };
399
400
409 static inline
410 int check_reply_recv(const comm_t *comm, char *data, const size_t len) {
411 int new_len = (int)len;
412 int ret = 0;
413 // Get reply
414 zmq_reply_t *zrep = (zmq_reply_t*)(comm->reply);
415 if (zrep == NULL) {
416 cislog_error("check_reply_recv(%s): Reply structure not initialized.", comm->name);
417 return -1;
418 }
419 zrep->n_msg++;
420 // Extract address
421 comm_head_t head = parse_comm_header(data, len);
422 char address[100];
423 size_t address_len;
424 if ((comm->is_work_comm == 1) && (zrep->nsockets == 1)) {
425 address_len = strlen(zrep->addresses[0]);
426 memcpy(address, zrep->addresses[0], address_len);
427 } else if (strlen(head.zmq_reply) > 0) {
428 address_len = strlen(head.zmq_reply);
429 memcpy(address, head.zmq_reply, address_len);
430 } else {
431 cislog_error("check_reply_recv(%s): Error parsing reply header in '%s'",
432 comm->name, data);
433 return -1;
434 }
435 address[address_len] = '\0';
436 // Match address and create if it dosn't exist
437 int isock = set_reply_recv(comm, address);
438 if (isock < 0) {
439 cislog_error("check_reply_recv(%s): Error setting reply socket.");
440 return -1;
441 }
442 // Confirm message receipt
443 ret = do_reply_recv(comm, isock, _reply_msg);
444 if (ret < 0) {
445 cislog_error("check_reply_recv(%s): Error during reply.", comm->name);
446 return -1;
447 }
448 return new_len;
449 };
450
456 static inline
457 int new_zmq_address(comm_t *comm) {
458 // TODO: Get protocol/host from input
459 char protocol[50] = "tcp";
460 char host[50] = "localhost";
461 char address[100];
462 if (strcmp(host, "localhost") == 0)
463 strcpy(host, "127.0.0.1");
464 if ((strcmp(protocol, "inproc") == 0) ||
465 (strcmp(protocol, "ipc") == 0)) {
466 // TODO: small chance of reusing same number
467 int key = 0;
468 if (!(_zmq_rand_seeded)) {
469 srand(ptr2seed(comm));
470 _zmq_rand_seeded = 1;
471 }
472 while (key == 0) key = rand();
473 if (strlen(comm->name) == 0)
474 sprintf(comm->name, "tempnewZMQ-%d", key);
475 sprintf(address, "%s://%s", protocol, comm->name);
476 } else {
477 if (_last_port_set == 0) {
478 cislog_debug("model_index = %s", getenv("CIS_MODEL_INDEX"));
479 _last_port = 49152 + 1000 * atoi(getenv("CIS_MODEL_INDEX"));
480 _last_port_set = 1;
481 cislog_debug("_last_port = %d", _last_port);
482 }
483 sprintf(address, "%s://%s:*[%d-]", protocol, host, _last_port + 1);
484 /* strcat(address, ":!"); // For random port */
485 }
486 // Bind
487 zsock_t *s = zsock_new(ZMQ_PAIR);
488 if (s == NULL) {
489 cislog_error("new_zmq_address: Could not initialize empty socket.");
490 return -1;
491 }
492 zsock_set_linger(s, 0);
493 int port = zsock_bind(s, "%s", address);
494 if (port == -1) {
495 cislog_error("new_zmq_address: Could not bind socket to address = %s",
496 address);
497 return -1;
498 }
499 // Add port to address
500 if ((strcmp(protocol, "inproc") != 0) &&
501 (strcmp(protocol, "ipc") != 0)) {
502 _last_port = port;
503 sprintf(address, "%s://%s:%d", protocol, host, port);
504 }
505 strcpy(comm->address, address);
506 cislog_debug("new_zmq_address: Bound socket to %s", comm->address);
507 if (strlen(comm->name) == 0)
508 sprintf(comm->name, "tempnewZMQ-%d", port);
509 comm->handle = (void*)s;
510 _cisSocketsCreated++;
511 // Init reply
512 int ret = init_zmq_reply(comm);
513 return ret;
514 };
515
521 static inline
522 int init_zmq_comm(comm_t *comm) {
523 int ret = -1;
524 if (comm->valid == 0)
525 return ret;
526 zsock_t *s = zsock_new(ZMQ_PAIR);
527 if (s == NULL) {
528 cislog_error("init_zmq_address: Could not initialize empty socket.");
529 return -1;
530 }
531 zsock_set_linger(s, 0);
532 ret = zsock_connect(s, "%s", comm->address);
533 if (ret == -1) {
534 cislog_error("init_zmq_address: Could not connect socket to address = %s",
535 comm->address);
536 zsock_destroy(&s);
537 return ret;
538 }
539 cislog_debug("init_zmq_address: Connected socket to %s", comm->address);
540 if (strlen(comm->name) == 0)
541 sprintf(comm->name, "tempinitZMQ-%s", comm->address);
542 // Asign to void pointer
543 comm->handle = (void*)s;
544 ret = init_zmq_reply(comm);
545 comm->always_send_header = 1;
546 return ret;
547 };
548
554 static inline
555 int free_zmq_comm(comm_t *x) {
556 int ret = 0;
557 if (x == NULL)
558 return ret;
559 // Drain input
560 if ((is_recv(x->direction)) && (x->valid == 1)) {
561 if (_cis_error_flag == 0) {
562 size_t data_len = 100;
563 char *data = (char*)malloc(data_len);
564 while (zmq_comm_nmsg(*x) > 0) {
565 ret = zmq_comm_recv(*x, &data, data_len, 1);
566 if (ret < 0) {
567 if (ret == -2) {
568 x->recv_eof[0] = 1;
569 break;
570 }
571 }
572 }
573 free(data);
574 }
575 }
576 // Free reply
577 if (x->reply != NULL) {
578 zmq_reply_t *zrep = (zmq_reply_t*)(x->reply);
579 // Free reply
580 ret = free_zmq_reply(zrep);
581 free(x->reply);
582 x->reply = NULL;
583 }
584 if (x->handle != NULL) {
585 zsock_t *s = (zsock_t*)(x->handle);
586 if (s != NULL) {
587 cislog_debug("Destroying socket: %s", x->address);
588 zsock_destroy(&s);
589 }
590 x->handle = NULL;
591 }
592 return ret;
593 };
594
600 static inline
601 int zmq_comm_nmsg(const comm_t x) {
602 int out = 0;
603 if (is_recv(x.direction)) {
604 if (x.handle != NULL) {
605 zsock_t *s = (zsock_t*)(x.handle);
606 zpoller_t *poller = zpoller_new(s, NULL);
607 if (poller == NULL) {
608 cislog_error("zmq_comm_nmsg: Could not create poller");
609 return -1;
610 }
611 void *p = zpoller_wait(poller, 1);
612 if (p == NULL) {
613 if (zpoller_terminated(poller)) {
614 cislog_error("zmq_comm_nmsg: Poller interrupted");
615 out = -1;
616 } else {
617 out = 0;
618 }
619 } else {
620 out = 1;
621 }
622 zpoller_destroy(&poller);
623 }
624 } else {
625 /* if (x.last_send[0] != 0) { */
626 /* time_t now; */
627 /* time(&now); */
628 /* double elapsed = difftime(now, x.last_send[0]); */
629 /* if (elapsed > _wait_send_t) */
630 /* out = 0; */
631 /* else */
632 /* out = 1; */
633 /* } */
634 zmq_reply_t *zrep = (zmq_reply_t*)(x.reply);
635 if (zrep != NULL) {
636 cislog_debug("zmq_comm_nmsg(%s): nmsg = %d, nrep = %d",
637 x.name, zrep->n_msg, zrep->n_rep);
638 out = zrep->n_msg - zrep->n_rep;
639 }
640 }
641 return out;
642 };
643
653 static inline
654 int zmq_comm_send(const comm_t x, const char *data, const size_t len) {
655 cislog_debug("zmq_comm_send(%s): %d bytes", x.name, len);
656 if (comm_base_send(x, data, len) == -1)
657 return -1;
658 zsock_t *s = (zsock_t*)(x.handle);
659 if (s == NULL) {
660 cislog_error("zmq_comm_send(%s): socket handle is NULL", x.name);
661 return -1;
662 }
663 int new_len = 0;
664 char *new_data = check_reply_send(&x, data, (int)len, &new_len);
665 if (new_data == NULL) {
666 cislog_error("zmq_comm_send(%s): Adding reply address failed.", x.name);
667 return -1;
668 }
669 zframe_t *f = zframe_new(new_data, new_len);
670 int ret = -1;
671 if (f == NULL) {
672 cislog_error("zmq_comm_send(%s): frame handle is NULL", x.name);
673 } else {
674 ret = zframe_send(&f, s, 0);
675 if (ret < 0) {
676 cislog_error("zmq_comm_send(%s): Error in zframe_send", x.name);
677 zframe_destroy(&f);
678 }
679 }
680 // Get reply
681 if (ret >= 0) {
682 ret = do_reply_send(&x);
683 if (ret < 0) {
684 if (ret == -2) {
685 cislog_error("zmq_comm_send(%s): EOF received", x.name);
686 } else {
687 cislog_error("zmq_comm_send(%s): Error in do_reply_send", x.name);
688 }
689 }
690 }
691 cislog_debug("zmq_comm_send(%s): returning %d", x.name, ret);
692 free(new_data);
693 return ret;
694 };
695
708 static inline
709 int zmq_comm_recv(const comm_t x, char **data, const size_t len,
710 const int allow_realloc) {
711 cislog_debug("zmq_comm_recv(%s)", x.name);
712 zsock_t *s = (zsock_t*)(x.handle);
713 if (s == NULL) {
714 cislog_error("zmq_comm_recv(%s): socket handle is NULL", x.name);
715 return -1;
716 }
717 while (1) {
718 int nmsg = zmq_comm_nmsg(x);
719 if (nmsg < 0) return -1;
720 else if (nmsg > 0) break;
721 else {
722 cislog_debug("zmq_comm_recv(%s): no messages, sleep", x.name);
723 usleep(CIS_SLEEP_TIME);
724 }
725 }
726 zframe_t *out = zframe_recv(s);
727 if (out == NULL) {
728 cislog_debug("zmq_comm_recv(%s): did not receive", x.name);
729 return -1;
730 }
731 size_t len_recv = zframe_size(out) + 1;
732 if (len_recv > len) {
733 if (allow_realloc) {
734 cislog_debug("zmq_comm_recv(%s): reallocating buffer from %d to %d bytes.",
735 x.name, len, len_recv);
736 (*data) = (char*)realloc(*data, len_recv);
737 if (*data == NULL) {
738 cislog_error("zmq_comm_recv(%s): failed to realloc buffer.", x.name);
739 zframe_destroy(&out);
740 return -1;
741 }
742 } else {
743 cislog_error("zmq_comm_recv(%s): buffer (%d bytes) is not large enough for message (%d bytes)",
744 x.name, len, len_recv);
745 zframe_destroy(&out);
746 return -((int)(len_recv - 1));
747 }
748 }
749 memcpy(*data, zframe_data(out), len_recv);
750 (*data)[len_recv-1] = '\0';
751 zframe_destroy(&out);
752 int ret = (int)len_recv - 1;
753 ret = check_reply_recv(&x, *data, (size_t)ret);
754 cislog_debug("zmq_comm_recv(%s): returning %d", x.name, ret);
755 return ret;
756 };
757
758
759 // Definitions in the case where ZMQ libraries not installed
760 #else /*ZMQINSTALLED*/
761
765 static inline
766 void zmq_install_error() {
767 cislog_error("Compiler flag 'ZMQINSTALLED' not defined so ZMQ bindings are disabled.");
768 };
769
775 static inline
776 int free_zmq_comm(comm_t *x) {
777 zmq_install_error();
778 return 1;
779 };
780
786 static inline
787 int new_zmq_address(comm_t *comm) {
788 zmq_install_error();
789 return -1;
790 };
791
797 static inline
798 int init_zmq_comm(comm_t *comm) {
799 zmq_install_error();
800 return -1;
801 };
802
808 static inline
809 int zmq_comm_nmsg(const comm_t x) {
810 zmq_install_error();
811 return -1;
812 };
813
823 static inline
824 int zmq_comm_send(const comm_t x, const char *data, const size_t len) {
825 zmq_install_error();
826 return -1;
827 };
828
841 static inline
842 int zmq_comm_recv(const comm_t x, char **data, const size_t len,
843 const int allow_realloc) {
844 zmq_install_error();
845 return -1;
846 };
847
853 static inline
854 char *set_reply_send(const comm_t *comm) {
855 zmq_install_error();
856 return NULL;
857 };
858
864 static inline
865 int set_reply_recv(const comm_t *comm, const char* address) {
866 zmq_install_error();
867 return -1;
868 };
869
870 #endif /*ZMQINSTALLED*/
871
872 #ifdef __cplusplus /* If this is a C++ compiler, end C linkage */
873 }
874 #endif
875
876 #endif /*CISZMQCOMM_H_*/
comm_t::handle
void * handle
Pointer to handle for comm.
Definition: CommBase.h:29
comm_t
Communication structure.
Definition: CommBase.h:23
comm_t::address
char address[COMM_ADDRESS_SIZE]
Comm address.
Definition: CommBase.h:26
comm_t::is_work_comm
int is_work_comm
Flag specifying if comm is a temporary work comm.
Definition: CommBase.h:41
comm_t::always_send_header
int always_send_header
1 if comm should always send a header.
Definition: CommBase.h:33
comm_head_t::zmq_reply
char zmq_reply[COMMBUFFSIZ]
Reply address for ZMQ sockets.
Definition: comm_header.h:34
comm_t::direction
char direction[COMM_DIR_SIZE]
send or recv for direction messages will go.
Definition: CommBase.h:27
comm_t::name
char name[COMM_NAME_SIZE]
Comm name.
Definition: CommBase.h:25
comm_t::valid
int valid
1 if communicator initialized, 0 otherwise.
Definition: CommBase.h:28
comm_t::recv_eof
int * recv_eof
Flag specifying if EOF has been received.
Definition: CommBase.h:37
comm_t::reply
void * reply
Reply information.
Definition: CommBase.h:39
comm_head_t
Header information passed by comms for multipart messages.
Definition: comm_header.h:19