本文整理汇总了C++中zstr_sendm函数的典型用法代码示例。如果您正苦于以下问题:C++ zstr_sendm函数的具体用法?C++ zstr_sendm怎么用?C++ zstr_sendm使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zstr_sendm函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: zyre_node_ping_peer
static int
zyre_node_ping_peer (const char *key, void *item, void *argument)
{
zyre_peer_t *peer = (zyre_peer_t *) item;
zyre_node_t *self = (zyre_node_t *) argument;
if (zclock_mono () >= zyre_peer_expired_at (peer)) {
if (self->verbose)
zsys_info ("(%s) peer expired name=%s endpoint=%s",
self->name, zyre_peer_name (peer), zyre_peer_endpoint (peer));
zyre_node_remove_peer (self, peer);
}
else
if (zclock_mono () >= zyre_peer_evasive_at (peer)) {
// If peer is being evasive, force a TCP ping.
// TODO: do this only once for a peer in this state;
// it would be nicer to use a proper state machine
// for peer management.
if (self->verbose)
zsys_info ("(%s) peer seems dead/slow name=%s endpoint=%s",
self->name, zyre_peer_name (peer), zyre_peer_endpoint (peer));
zre_msg_t *msg = zre_msg_new (ZRE_MSG_PING);
zyre_peer_send (peer, &msg);
// Inform the calling application this peer is being evasive
zstr_sendm (self->outbox, "EVASIVE");
zstr_sendm (self->outbox, zyre_peer_identity (peer));
zstr_send (self->outbox, zyre_peer_name (peer));
}
return 0;
}
示例2: fmq_server_setoption
void
fmq_server_setoption (fmq_server_t *self, const char *path, const char *value)
{
zstr_sendm (self->pipe, "SETOPTION");
zstr_sendm (self->pipe, path);
zstr_send (self->pipe, value);
}
示例3: zre_node_publish
void
zre_node_publish (zre_node_t *self, char *logical, char *physical)
{
zstr_sendm (self->pipe, "PUBLISH");
zstr_sendm (self->pipe, logical);
zstr_send (self->pipe, physical);
}
示例4: main
int main (int argc, char *argv [])
{
zctx_t *context = zctx_new ();
void *publisher = zsocket_new (context, ZMQ_PUB);
if (argc == 2)
zsocket_connect (publisher, argv [1]);
else
zsocket_bind (publisher, "tcp://*:5556");
// Ensure subscriber connection has time to complete
sleep (1);
// Send out all 1,000 topic messages
int topic_nbr;
for (topic_nbr = 0; topic_nbr < 1000; topic_nbr++) {
zstr_sendm (publisher, "%03d", topic_nbr, ZMQ_SNDMORE);
zstr_send (publisher, "Save Roger");
}
// Send one random update per second
srandom ((unsigned) time (NULL));
while (!zctx_interrupted) {
sleep (1);
zstr_sendm (publisher, "%03d", randof (1000), ZMQ_SNDMORE);
zstr_send (publisher, "Off with his head!");
}
zctx_destroy (&context);
return 0;
}
示例5: zyre_node_stop
static int
zyre_node_stop (zyre_node_t *self)
{
if (self->beacon) {
// Stop broadcast/listen beacon
beacon_t beacon;
beacon.protocol [0] = 'Z';
beacon.protocol [1] = 'R';
beacon.protocol [2] = 'E';
beacon.version = BEACON_VERSION;
beacon.port = 0; // Zero means we're stopping
zuuid_export (self->uuid, beacon.uuid);
zsock_send (self->beacon, "sbi", "PUBLISH",
(byte *) &beacon, sizeof (beacon_t), self->interval);
zclock_sleep (1); // Allow 1 msec for beacon to go out
zpoller_remove (self->poller, self->beacon);
zactor_destroy (&self->beacon);
}
// Stop polling on inbox
zpoller_remove (self->poller, self->inbox);
zstr_sendm (self->outbox, "STOP");
zstr_sendm (self->outbox, zuuid_str (self->uuid));
zstr_send (self->outbox, self->name);
return 0;
}
示例6: zre_interface_publish
// Publish file into virtual space
void
zre_interface_publish (zre_interface_t *self,
char *filename, char *external)
{
zstr_sendm (self->pipe, "PUBLISH");
zstr_sendm (self->pipe, filename); // Real file name
zstr_send (self->pipe, external); // Location in virtual space
}
示例7: zyre_whisper
int
zyre_whisper (zyre_t *self, const char *peer, zmsg_t **msg_p)
{
assert (self);
assert (peer);
zstr_sendm (self->actor, "WHISPER");
zstr_sendm (self->actor, peer);
zmsg_send (msg_p, self->actor);
return 0;
}
示例8: zyre_shout
int
zyre_shout (zyre_t *self, const char *group, zmsg_t **msg_p)
{
assert (self);
assert (group);
zstr_sendm (self->actor, "SHOUT");
zstr_sendm (self->actor, group);
zmsg_send (msg_p, self->actor);
return 0;
}
示例9: curve_client_connect
void
curve_client_connect (curve_client_t *self, char *endpoint, byte *server_key)
{
assert (self);
assert (endpoint);
assert (server_key);
zstr_sendm (self->control, "CONNECT");
zstr_sendm (self->control, endpoint);
zmq_send (self->control, server_key, 32, 0);
}
示例10: zyre_peer_header_value
char *
zyre_peer_header_value (zyre_t *self, const char *peer, const char *name)
{
assert (self);
assert (peer);
assert (name);
zstr_sendm (self->actor, "PEER HEADER");
zstr_sendm (self->actor, peer);
zstr_send (self->actor, name);
return zstr_recv (self->actor);
}
示例11: zyre_node_leave_peer_group
static zyre_group_t *
zyre_node_leave_peer_group (zyre_node_t *self, zyre_peer_t *peer, char *name)
{
zyre_group_t *group = zyre_node_require_peer_group (self, name);
zyre_group_leave (group, peer);
// Now tell the caller about the peer left group
zstr_sendm (self->pipe, "LEAVE");
zstr_sendm (self->pipe, zyre_peer_identity (peer));
zstr_send (self->pipe, name);
return group;
}
示例12: zyre_node_join_peer_group
static zyre_group_t *
zyre_node_join_peer_group (zyre_node_t *self, zyre_peer_t *peer, char *name)
{
zyre_group_t *group = zyre_node_require_peer_group (self, name);
zyre_group_join (group, peer);
// Now tell the caller about the peer joined group
zstr_sendm (self->pipe, "JOIN");
zstr_sendm (self->pipe, zyre_peer_identity (peer));
zstr_send (self->pipe, name);
return group;
}
示例13: zre_interface_header_set
void
zre_interface_header_set (zre_interface_t *self, char *name, char *format, ...)
{
assert (self);
va_list argptr;
va_start (argptr, format);
char *value = (char *) malloc (255 + 1);
vsnprintf (value, 255, format, argptr);
va_end (argptr);
zstr_sendm (self->pipe, "SET");
zstr_sendm (self->pipe, name);
zstr_send (self->pipe, value);
free (value);
}
示例14: s_require_peer
static zre_peer_t *
s_require_peer (agent_t *self, char *identity, char *address, uint16_t port)
{
zre_peer_t *peer = (zre_peer_t *) zhash_lookup (self->peers, identity);
if (!peer) {
// Purge any previous peer on same endpoint
char endpoint [100];
snprintf (endpoint, 100, "%s:%hu", address, port);
zhash_foreach (self->peers, agent_peer_purge, endpoint);
peer = zre_peer_new (identity, self->peers, self->ctx);
zre_peer_connect (peer, self->identity, endpoint);
// Handshake discovery by sending HELLO as first message
zre_msg_t *msg = zre_msg_new (ZRE_MSG_HELLO);
zre_msg_ipaddress_set (msg, zre_udp_host (self->udp));
zre_msg_mailbox_set (msg, self->port);
zre_msg_groups_set (msg, zhash_keys (self->own_groups));
zre_msg_status_set (msg, self->status);
zre_msg_headers_set (msg, zhash_dup (self->headers));
zre_peer_send (peer, &msg);
zre_log_info (self->log, ZRE_LOG_MSG_EVENT_ENTER,
zre_peer_endpoint (peer), endpoint);
// Now tell the caller about the peer
zstr_sendm (self->pipe, "ENTER");
zstr_send (self->pipe, identity);
}
return peer;
}
示例15: fmq_server_set_anonymous
void
fmq_server_set_anonymous (fmq_server_t *self, long enabled)
{
assert (self);
zstr_sendm (self->pipe, "SET ANONYMOUS");
zstr_sendf (self->pipe, "%ld", enabled);
}