- 论坛徽章:
- 0
|
uint8_t id[256];
size_t id_size;
rc = zmq_getsockopt(socket, ZMQ_IDENTITY, id, &id_size);
zmq_send(socket, id, id_size, ZMQ_DONTWAIT);
int sn = zmq_send(socket,sndbuf,nLen,ZMQ_DONTWAIT);
ZMQ_STREAM
A socket of type ZMQ_STREAM is used to send and receive TCP data from a non-ØMQ peer, when using the tcp:// transport. A ZMQ_STREAM socket can act as client and/or server, sending and/or receiving TCP data asynchronously.
When receiving TCP data, a ZMQ_STREAM socket shall prepend a message part containing the identity of the originating peer to the message before passing it to the application. Messages received are fair-queued from among all connected peers.
When sending TCP data, a ZMQ_STREAM socket shall remove the first part of the message and use it to determine the identity of the peer the message shall be routed to, and unroutable messages shall cause an EHOSTUNREACH or EAGAIN error.
To open a connection to a server, use the zmq_connect call, and then fetch the socket identity using the ZMQ_IDENTITY zmq_getsockopt call.
To close a specific client connection, as a server, send the identity frame followed by a zero-length message (see EXAMPLE section). |
|