Is there a reason why you don't use JZMQ or JeroMQ? I am not sure what you are trying to achieve here but your code Works As Designed™.
You are doing a zstr_recv() which itself uses zmsg_recv() without any flags to read messages from a socket. http://api.zeromq.org/4-2:zmq-msg-recv > If there are no message parts available on the specified socket the > zmq_msg_recv() function shall block until the request can be satisfied. Afaics neither zstr nor zmsg implement a timeout for now. You could use zmsg_msg_recv() and pass ZMQ_DONTWAIT and implement your own timeout handling. 2016-03-15 8:43 GMT+01:00 Bachmair Florian - flexSolution GmbH <[email protected]>: > Hi! > > Is there a way to get a Timeout for a Request? > If I send a Request, it "hangs" till the other side Responses. If the > other Side is not up, I never get a response. > I would like to detect this on the Request side. Is that possible? > > > my current request code is: > > JNIEXPORT jstring JNICALL core_JNI_1zeromq_request( > JNIEnv *env, jobject object, jstring address, jstring timestamp, > jstring sender, jstring command, jstring message) { > const char* addr = (*env)->GetStringUTFChars(env, address, 0); > const char* ts = (*env)->GetStringUTFChars(env, timestamp, 0); > const char* s = (*env)->GetStringUTFChars(env, sender, 0); > const char* cmd = (*env)->GetStringUTFChars(env, command, 0); > const char* msg = (*env)->GetStringUTFChars(env, message, 0); > > > fflush(stdout); > void *req = zsocket_new(context, ZMQ_REQ); > int rc = zsocket_connect(req, "%s", addr); > > assert(rc == 0); > s_sendmore(req, ts); > s_sendmore(req, s); > s_sendmore(req, cmd); > s_send(req, msg); > > char* reply = zstr_recv(req); > > zsocket_destroy(context, req); > > (*env)->ReleaseStringUTFChars(env, timestamp, ts); > (*env)->ReleaseStringUTFChars(env, sender, s); > (*env)->ReleaseStringUTFChars(env, message, msg); > > jstring ret = (*env)->NewStringUTF(env, reply); > return ret; > } > > > Thank you > _______________________________________________ > zeromq-dev mailing list > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev -- Mario Steinhoff https://github.com/msteinhoff https://twitter.com/msteinhofff T: +49 173 7265158 In der Gelpe 79 42349 Wuppertal _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
