JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1unbind (JNIEnv *env, jclass c, jlong self, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); jint unbind_ = (jint) zsock_unbind ((zsock_t *) (intptr_t) self, "%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); return unbind_; }
static void s_self_destroy (self_t **self_p) { assert (self_p); if (*self_p) { self_t *self = *self_p; zhashx_destroy (&self->passwords); zhashx_destroy (&self->whitelist); zhashx_destroy (&self->blacklist); zcertstore_destroy (&self->certstore); zpoller_destroy (&self->poller); if (self->handler) { zsock_unbind (self->handler, ZAP_ENDPOINT); zsock_destroy (&self->handler); } free (self); *self_p = NULL; } }
/// // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int QZsock::unbind (const QString ¶m) { int rv = zsock_unbind (self, "%s", param.toUtf8().data()); return rv; }
void zsock_test (bool verbose) { printf (" * zsock: "); // @selftest zsock_t *writer = zsock_new_push ("@tcp://127.0.0.1:5560"); assert (writer); assert (zsock_resolve (writer) != writer); assert (streq (zsock_type_str (writer), "PUSH")); int rc; #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3,2,0)) // Check unbind rc = zsock_unbind (writer, "tcp://127.0.0.1:%d", 5560); assert (rc == 0); // In some cases and especially when running under Valgrind, doing // a bind immediately after an unbind causes an EADDRINUSE error. // Even a short sleep allows the OS to release the port for reuse. zclock_sleep (100); // Bind again rc = zsock_bind (writer, "tcp://127.0.0.1:%d", 5560); assert (rc == 5560); assert (streq (zsock_endpoint (writer), "tcp://127.0.0.1:5560")); #endif zsock_t *reader = zsock_new_pull (">tcp://127.0.0.1:5560"); assert (reader); assert (zsock_resolve (reader) != reader); assert (streq (zsock_type_str (reader), "PULL")); zstr_send (writer, "Hello, World"); zmsg_t *msg = zsock_recv (reader); assert (msg); char *string = zmsg_popstr (msg); assert (streq (string, "Hello, World")); free (string); zmsg_destroy (&msg); // Test binding to ephemeral ports, sequential and random int port = zsock_bind (writer, "tcp://127.0.0.1:*"); assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:*[50000-]"); assert (port >= 50000 && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:*[-50001]"); assert (port >= DYNAMIC_FIRST && port <= 50001); port = zsock_bind (writer, "tcp://127.0.0.1:*[60000-60010]"); assert (port >= 60000 && port <= 60010); port = zsock_bind (writer, "tcp://127.0.0.1:!"); assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:![50000-]"); assert (port >= 50000 && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:![-50001]"); assert (port >= DYNAMIC_FIRST && port <= 50001); port = zsock_bind (writer, "tcp://127.0.0.1:![60000-60010]"); assert (port >= 60000 && port <= 60010); // Test zsock_endpoint method rc = zsock_bind (writer, "inproc://test.%s", "writer"); assert (rc == 0); assert (streq (zsock_endpoint (writer), "inproc://test.writer")); // Test error state when connecting to an invalid socket type // ('txp://' instead of 'tcp://', typo intentional) rc = zsock_connect (reader, "txp://127.0.0.1:5560"); assert (rc == -1); rc = zsock_signal (writer, 123); assert (rc == 0); rc = zsock_wait (reader); assert (rc == 123); zsock_destroy (&reader); zsock_destroy (&writer); // Test zsock_attach method zsock_t *server = zsock_new (ZMQ_DEALER); rc = zsock_attach (server, "@inproc://myendpoint,tcp://127.0.0.1:5556,inproc://others", true); assert (rc == 0); rc = zsock_attach (server, "", false); assert (rc == 0); rc = zsock_attach (server, NULL, true); assert (rc == 0); rc = zsock_attach (server, ">a,@b, c,, ", false); assert (rc == -1); zsock_destroy (&server); // @end printf ("OK\n"); }
Z K2(zsockunbind){PC(x); TC(y,-KS); R kj(zsock_unbind(VSK(x),ys));}
/// // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int QmlZsock::unbind (const QString &format) { return zsock_unbind (self, "%s", format.toUtf8().data()); };