[zeromq-dev] assertion failed on zsocket_connect with ZMQ_REQ

Bachmair Florian - flexSolution GmbH florian.bachmair at flexsolution.eu
Tue May 19 09:40:33 CEST 2015


Sometimes I get an assertion failed in my code.
Why is this? shouldn't it block, till a connection is established?

NIEXPORT jstring JNICALL Java_eu_flexsolution_core_JNI_1zeromq_request(
         JNIEnv *env, jobject object, jstring address, jstring timestamp,
         jstring format, jstring command, jstring message) {
     const char* addr = (*env)->GetStringUTFChars(env, address, 0);
     const char* ts = (*env)->GetStringUTFChars(env, timestamp, 0);
     const char* f = (*env)->GetStringUTFChars(env, format, 0);
     const char* cmd = (*env)->GetStringUTFChars(env, command, 0);
     const char* msg = (*env)->GetStringUTFChars(env, message, 0);

     printf("REQ:%s:%s:%s:%s:%s\n", addr,cmd, msg, f, ts);
     void *req = zsocket_new(context, ZMQ_REQ);
     int rc = zsocket_connect(req, "%s", addr);
     assert(rc == 0);
     s_sendmore(req, ts);
     s_sendmore(req, f);
     s_sendmore(req, cmd);
     s_send(req, msg);

     char* reply = s_recv(req);
     printf("reply: %s\n", reply);

     (*env)->ReleaseStringUTFChars(env, timestamp, ts);
     (*env)->ReleaseStringUTFChars(env, format, f);
     (*env)->ReleaseStringUTFChars(env, message, msg);

     jstring ret = (*env)->NewStringUTF(env, reply);
     return ret;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20150519/c9f7b62f/attachment.htm>

More information about the zeromq-dev mailing list