本文整理汇总了C++中zstr_sendx函数的典型用法代码示例。如果您正苦于以下问题:C++ zstr_sendx函数的具体用法?C++ zstr_sendx怎么用?C++ zstr_sendx使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zstr_sendx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: zyre_set_zcert
void zyre_set_zcert(zyre_t *self, zcert_t *zcert)
{
assert (zcert);
// actor will assert check the keys
zstr_sendx (self->actor, "SET PUBLICKEY", zcert_public_txt(zcert), NULL);
zstr_sendx (self->actor, "SET SECRETKEY", zcert_secret_txt(zcert), NULL);
}
示例2: zpipes_client_test
void
zpipes_client_test (bool verbose)
{
printf (" * zpipes_client: ");
// @selftest
zactor_t *server = zactor_new (zpipes_server, NULL);
zstr_sendx (server, "SET", "server/animate", verbose? "1": "0", NULL);
zstr_sendx (server, "BIND", "ipc://@/zpipes/local", NULL);
zpipes_client_t *reader = zpipes_client_new ("local", "test pipe");
zpipes_client_t *writer = zpipes_client_new ("local", ">test pipe");
byte buffer [100];
ssize_t bytes;
// Expect timeout error, EAGAIN
bytes = zpipes_client_read (reader, buffer, 6, 100);
assert (bytes == -1);
assert (zpipes_client_error (reader) == EAGAIN);
bytes = zpipes_client_write (writer, "CHUNK1", 6, 100);
assert (bytes == 6);
bytes = zpipes_client_write (writer, "CHUNK2", 6, 100);
assert (bytes == 6);
bytes = zpipes_client_write (writer, "CHUNK3", 6, 100);
assert (bytes == 6);
bytes = zpipes_client_read (reader, buffer, 1, 100);
assert (bytes == 1);
bytes = zpipes_client_read (reader, buffer, 10, 100);
assert (bytes == 10);
// Now close writer
zpipes_client_destroy (&writer);
// Expect end of pipe (short read)
bytes = zpipes_client_read (reader, buffer, 50, 100);
assert (bytes == 7);
// Expect end of pipe (empty chunk)
bytes = zpipes_client_read (reader, buffer, 50, 100);
assert (bytes == 0);
// Expect illegal action (EBADF) writing on reader
bytes = zpipes_client_write (reader, "CHUNK1", 6, 100);
assert (bytes == -1);
assert (zpipes_client_error (reader) == EBADF);
zpipes_client_destroy (&reader);
zpipes_client_destroy (&writer);
zactor_destroy (&server);
// @end
printf ("OK\n");
}
示例3: s_bind_proxy_sockets
static void
s_bind_proxy_sockets (zactor_t *proxy, char **frontend, char **backend)
{
if (*frontend)
zstr_free (frontend);
if (*backend)
zstr_free (backend);
*frontend = zsys_sprintf (LOCALENDPOINT, s_get_available_port ());
*backend = zsys_sprintf (LOCALENDPOINT, s_get_available_port ());
zstr_sendx (proxy, "FRONTEND", "PULL", *frontend, NULL);
zsock_wait (proxy);
zstr_sendx (proxy, "BACKEND", "PUSH", *backend, NULL);
zsock_wait (proxy);
}
示例4: zyre_stop
void
zyre_stop (zyre_t *self)
{
assert (self);
zstr_sendx (self->actor, "STOP", NULL);
zsock_wait (self->actor);
}
示例5: main
int main(int argc, char **argv) {
//
//
const char *config_file = "malamute.cfg";
if (argc >= 2)
config_file = argv[1];
// Start Malamute server instance
zactor_t *server = zactor_new (mlm_server, "Malamute");
zstr_sendx (server, "LOAD", config_file, NULL);
// Accept and print any message back from server
while (true) {
char *message = zstr_recv (server);
if (message) {
puts (message);
free (message);
}
else {
puts ("interrupted");
break;
}
}
// Shutdown all services
zactor_destroy (&server);
return EXIT_SUCCESS;
}
示例6: server_accept
static void
server_accept (server_t *self, const char *key, const char *value)
{
tuple_t *tuple = (tuple_t *) zhash_lookup (self->tuples, key);
if (tuple && streq (tuple->value, value))
return; // Duplicate tuple, do nothing
// Create new tuple
tuple = (tuple_t *) zmalloc (sizeof (tuple_t));
assert (tuple);
tuple->container = self->tuples;
tuple->key = strdup (key);
tuple->value = strdup (value);
// Store new tuple
zhash_update (tuple->container, key, tuple);
zhash_freefn (tuple->container, key, tuple_free);
// Deliver to calling application
zstr_sendx (self->pipe, "DELIVER", key, value, NULL);
// Hold in server context so we can broadcast to all clients
self->cur_tuple = tuple;
engine_broadcast_event (self, NULL, forward_event);
// Copy new tuple announcement to all remotes
zsock_t *remote = (zsock_t *) zlist_first (self->remotes);
while (remote) {
int rc = zgossip_msg_send_publish (remote, key, value, 0);
assert (rc == 0);
remote = (zsock_t *) zlist_next (self->remotes);
}
}
示例7: zyre_join
int
zyre_join (zyre_t *self, const char *group)
{
assert (self);
zstr_sendx (self->actor, "JOIN", group, NULL);
return 0;
}
示例8: mdp_broker_test
void
mdp_broker_test (bool verbose)
{
printf (" * mdp_broker: ");
if (verbose)
printf ("\n");
// @selftest
zactor_t *server = zactor_new (mdp_broker, "server");
if (verbose)
zstr_send (server, "VERBOSE");
zstr_sendx (server, "BIND", "ipc://@/mdp_broker", NULL);
zsock_t *client = zsock_new (ZMQ_DEALER);
assert (client);
zsock_set_rcvtimeo (client, 2000);
zsock_connect (client, "ipc://@/mdp_broker");
// TODO: fill this out
mdp_msg_t *request = mdp_msg_new ();
mdp_msg_destroy (&request);
zsock_destroy (&client);
zactor_destroy (&server);
// @end
printf ("OK\n");
}
示例9: zyre_new
zyre_t *
zyre_new (const char *name)
{
zyre_t *self = (zyre_t *) zmalloc (sizeof (zyre_t));
assert (self);
// Create front-to-back pipe pair for data traffic
self->inbox = zsock_new (ZMQ_PAIR);
assert (self->inbox);
char endpoint [32];
while (true) {
sprintf (endpoint, "inproc://zyre-%04x-%04x\n",
randof (0x10000), randof (0x10000));
if (zsock_bind (self->inbox, "%s", endpoint) == 0)
break;
}
// Create other half of traffic pipe
zsock_t *outbox = zsock_new_pair (endpoint);
assert (outbox);
// Start node engine and wait for it to be ready
self->actor = zactor_new (zyre_node_actor, outbox);
assert (self->actor);
// Send name, if any, to node ending
if (name)
zstr_sendx (self->actor, "SET NAME", name, NULL);
return self;
}
示例10: main
int main (void) {
zsys_set_ipv6 (1);
zactor_t *root = zactor_new (zgossip, "root");
assert (root);
int rc = 0;
rc = zstr_sendx (root, "BIND", "tcp://*:5670", NULL);
assert (rc == 0);
zloop_t *reactor = zloop_new ();
assert (reactor);
zloop_set_verbose (reactor, true);
rc = zloop_reader (reactor, root, handle_pipe, NULL);
assert (rc == 0);
zloop_start (reactor);
zloop_destroy (&reactor);
zactor_destroy (&root);
return 0;
}
示例11: zyre_leave
int
zyre_leave (zyre_t *self, const char *group)
{
assert (self);
zstr_sendx (self->actor, "LEAVE", group, NULL);
return 0;
}
示例12: zyre_start
int
zyre_start (zyre_t *self)
{
assert (self);
zstr_sendx (self->actor, "START", NULL);
return zsock_wait (self->actor) == 0? 0: -1;
}
示例13: zauth_allow
void
zauth_allow (zauth_t *self, char *address)
{
zstr_sendx (self->pipe, "ALLOW", address, NULL);
// Wait for completion
free (zstr_recv (self->pipe));
}
示例14: zauth_deny
void
zauth_deny (zauth_t *self, char *address)
{
zstr_sendx (self->pipe, "DENY", address, NULL);
// Wait for completion
free (zstr_recv (self->pipe));
}
示例15: zauth_configure_gssapi
void
zauth_configure_gssapi (zauth_t *self, char *domain)
{
assert (self);
assert (domain);
zstr_sendx (self->pipe, "GSSAPI", domain, NULL);
zsocket_wait (self->pipe);
}