static void s_upstream_handle_pipe (upstream_t *self) { char *command = zstr_recv (self->pipe); if (streq (command, "$TERM")) { self->terminated = true; } else if (streq (command, "CONNECT")) { char *endpoint = zstr_recv (self->pipe); int rc = zsock_connect (self->push, "%s", endpoint); if (rc != -1) self->connected = true; zstr_free (&endpoint); zsock_bsend (self->pipe, "2", rc); } else if (streq (command, "BIND")) { char *endpoint = zstr_recv (self->pipe); int rc = zsock_bind (self->push, "%s", endpoint); if (rc != -1) self->connected = true; zstr_free (&endpoint); zsock_bsend (self->pipe, "2", rc); } else if (streq (command, "SET_SIZE")) { int64_t size; zsock_brecv (self->pipe, "8", &size); self->size = size; } else if (streq (command, "GET_SIZE")) { zsock_bsend (self->pipe, "8", self->size); } else if (streq (command, "SET_VARIANCE")) { int64_t variance; zsock_brecv (self->pipe, "8", &variance); self->variance = variance; } else if (streq (command, "GET_VARIANCE")) { zsock_bsend (self->pipe, "8", self->variance); } else { zsys_error ("upstream: invalid command: %s", command); assert (false); } zstr_free (&command); }
int64_t upstream_get_variance (zactor_t *upstream) { zstr_send (upstream, "GET_VARIANCE"); int64_t variance; zsock_brecv (upstream, "8", &variance); return variance; }
int64_t upstream_get_size (zactor_t *upstream) { zstr_send (upstream, "GET_SIZE"); int64_t size; zsock_brecv (upstream, "8", &size); return size; }
JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1brecv (JNIEnv *env, jclass c, jlong self, jstring picture) { char *picture_ = (char *) (*env)->GetStringUTFChars (env, picture, NULL); jint brecv_ = (jint) zsock_brecv ((zsock_t *) (intptr_t) self, picture_); (*env)->ReleaseStringUTFChars (env, picture, picture_); return brecv_; }
int upstream_bind (zactor_t *upstream, char *endpoint) { zstr_sendm (upstream, "BIND"); zstr_send (upstream, endpoint); int rc; zsock_brecv (upstream, "2", &rc); return rc; }
int upstream_connect (zactor_t *upstream, char *endpoint) { zstr_sendm (upstream, "CONNECT"); zstr_send (upstream, endpoint); int rc; zsock_brecv (upstream, "2", &rc); return rc; }
static int s_forward_stream_traffic (zloop_t *loop, zsock_t *reader, void *argument) { client_t *client; mlm_msg_t *msg; zsock_brecv (reader, "pp", &client, &msg); assert (client); assert (!client->msg); client->msg = msg; engine_send_event (client, stream_message_event); assert (!client->msg); return 0; }
static int s_stream_engine_handle_message (stream_engine_t *self) { void *sender; mlm_msg_t *msg; zsock_brecv (self->msgpipe, "pp", &sender, &msg); selector_t *selector = (selector_t *) zlistx_first (self->selectors); while (selector) { if (zrex_matches (selector->rex, mlm_msg_subject (msg))) { void *client = zlistx_first (selector->clients); while (client) { if (client != sender) zsock_bsend (self->msgpipe, "pp", client, mlm_msg_link (msg)); client = zlistx_next (selector->clients); } } selector = (selector_t *) zlistx_next (self->selectors); } mlm_msg_unlink (&msg); return 0; }
static int s_forward_stream_traffic (zloop_t *loop, zsock_t *reader, void *argument) { client_t *client; mlm_msg_t *msg; zsock_brecv (reader, "pp", &client, &msg); assert (client); if (msg == MLM_STREAM_ACK_CANCEL) { // This is an ACK for a previously sent CANCEL command engine_client_put (client); return 0; } // We may be receiving messages for an already dropped client if (!engine_client_is_valid (client)) { mlm_msg_unlink (&msg); return 0; } assert (!client->msg); client->msg = msg; engine_send_event (client, stream_message_event); assert (!client->msg); return 0; }
Z K2(zsockbrecv){PC(x); TC(y,-KS); R kj(zsock_brecv(VSK(x), ys));}
/// // Receive a binary encoded 'picture' message from the socket (or actor). // This method is similar to zsock_recv, except the arguments are encoded // in a binary format that is compatible with zproto, and is designed to // reduce memory allocations. The pattern argument is a string that defines // the type of each argument. See zsock_bsend for the supported argument // types. All arguments must be pointers; this call sets them to point to // values held on a per-socket basis. // Note that zsock_brecv creates the returned objects, and the caller must // destroy them when finished with them. The supplied pointers do not need // to be initialized. Returns 0 if successful, or -1 if it failed to read // a message. int QmlZsock::brecv (const QString &picture) { return zsock_brecv (self, picture.toUtf8().data()); };