[zeromq-dev] Help: epgm pub/sub does not work

Wang, Xin (WorldQuant) Xin.Wang at worldquant.com
Mon Jul 29 17:01:18 CEST 2013


I installed zmq stable release 3.2.3 and czmq 1.4.1 recently, and I'm having issues with epgm with pub/sub pattern.

On server side, I have the following code and it seems to work.
  zctx_t *ctx = zctx_new();
  void *publisher = zsocket_new(ctx, ZMQ_PUB);
int rc = zsocket_bind(publisher, "epgm:// 10.88.150.227:5555");

netstat shows the following:
udp        0      0 0.0.0.0:5555                0.0.0.0:*


On the client side, zsocket_connect always returns -1 (error message invalid argument)
  void *subscriber = zsocket_new(ctx, ZMQ_SUB);
int rc = zsocket_connect(subscriber, "epgm://10.88.150.227:5555");

I also tried the following on the client side, and it returned the same error.
  void *subscriber = zsocket_new(ctx, ZMQ_SUB);
int rc = zsocket_connect(subscriber, "epgm://eth0;10.88.150.227:5555");

The system I'm working on is centerOS 5.5, and linux kernel is 2.6.18. The code is below. The same code works perfect if I use tcp instead of epgm for both server and client.

What could go wrong here with epgm? Thanks.

Xin


Server:
#include "czmq.h"
#include "stdio.h"
#include "error.h"

int main() {
  zctx_t *ctx = zctx_new();
  void *publisher = zsocket_new(ctx, ZMQ_PUB);
  int rc = zsocket_bind(publisher, "epgm://10.88.150.227:5555");
  if (rc == -1) {
    printf("return code: %d\n%s\n", rc, zmq_strerror(zmq_errno()));
    return rc;
  }
  printf("return code: %d\n", rc);
  //zsocket_bind(publisher, "tcp://wqsim005:5555");
  int count = 0;
  while (!zctx_interrupted) {
    char string[10];
    sprintf(string, "%c-%05d", randof(3) + 'A', randof(100000));
    if (zstr_send(publisher, string) == -1)
      break;
    printf("send %d: %s\n", count, string);
    ++count;
    //zclock_sleep((randof(60)+1) * 1000);
    zclock_sleep(2000);
  }
  zsocket_destroy(ctx, publisher);
  zctx_destroy(&ctx);
  return 0;
}

Client:
#include "czmq.h"
#include "stdio.h"

int main() {
  zctx_t *ctx = zctx_new();
  void *subscriber = zsocket_new(ctx, ZMQ_SUB);
  int rc = zsocket_connect(subscriber, "epgm://10.88.150.227:5555");
  if (rc == -1) {
    printf("return code: %d\n%s\n", rc, strerror(errno));
    return rc;
  }
  printf("return code: %d\n", rc);
  zsocket_set_subscribe(subscriber, "A");
  zsocket_set_subscribe(subscriber, "B");
  //zsocket_connect(subscriber, "tcp://wqsim005:5555");
  int count = 0;
  while (!zctx_interrupted) {
    char * string = zstr_recv(subscriber);
    if (!string)
      break;
    printf("recv %d: %s\n", count, string);
    fflush(stdout);
    free(string);
    count ++;
  }
  zsocket_destroy(ctx, subscriber);
  zctx_destroy(&ctx);
  return 0;
}


###################################################################################
The information contained in this communication is confidential, may be
subject to legal privilege, and is intended only for the individual named.
If you are not the named addressee, please notify the sender immediately and
delete this email from your system.  The views expressed in this email are
the views of the sender only.  Outgoing and incoming electronic communications
to this address are electronically archived and subject to review and/or disclosure
to someone other than the recipient.
###################################################################################
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130729/27fd25f8/attachment.htm>


More information about the zeromq-dev mailing list