|
| 1 | += zmq_disconnect_peer(3) |
| 2 | + |
| 3 | + |
| 4 | +== NAME |
| 5 | +zmq_disconnect_peer - disconnect a specific peer connection by routing id. |
| 6 | + |
| 7 | + |
| 8 | +== SYNOPSIS |
| 9 | +*int zmq_disconnect_peer (void '*socket', uint32_t 'routing_id');* |
| 10 | + |
| 11 | + |
| 12 | +== DESCRIPTION |
| 13 | +The _zmq_disconnect_peer()_ function disconnects a specific connection from a |
| 14 | +socket given the peer 'routing_id'. After a successful disconnection, attempts |
| 15 | +to send messages addressed with that 'routing_id' will fail with 'EHOSTUNREACH' |
| 16 | +until a new connection with a different 'routing_id' is established. |
| 17 | + |
| 18 | +This function is supported on socket types that manage per-peer routing ids: |
| 19 | +'ZMQ_SERVER' and 'ZMQ_PEER'. Calling it on other socket types will fail with |
| 20 | +'ENOTSUP'. |
| 21 | + |
| 22 | + |
| 23 | +== RETURN VALUE |
| 24 | +The _zmq_disconnect_peer()_ function returns `0` if successful. Otherwise it |
| 25 | +returns `-1` and sets 'errno' to one of the values defined below. |
| 26 | + |
| 27 | + |
| 28 | +== ERRORS |
| 29 | +*EHOSTUNREACH*:: |
| 30 | +No connection exists for the given 'routing_id'. |
| 31 | +*ENOTSUP*:: |
| 32 | +The socket type does not support disconnecting by 'routing_id'. |
| 33 | +*ENOTSOCK*:: |
| 34 | +The provided 'socket' was invalid. |
| 35 | +*ETERM*:: |
| 36 | +The 0MQ 'context' associated with the specified 'socket' was terminated. |
| 37 | + |
| 38 | + |
| 39 | +== EXAMPLE |
| 40 | +.Disconnect a peer by routing id |
| 41 | +---- |
| 42 | +void *server = zmq_socket (context, ZMQ_SERVER); |
| 43 | +assert (server); |
| 44 | +assert (zmq_bind (server, "tcp://*:5555") == 0); |
| 45 | +/* ... receive a message and read its routing id ... */ |
| 46 | +uint32_t routing_id = /* obtained from zmq_msg_routing_id(...) */; |
| 47 | +/* Disconnect that specific peer */ |
| 48 | +int rc = zmq_disconnect_peer (server, routing_id); |
| 49 | +assert (rc == 0); |
| 50 | +/* Any attempt to send to that routing id now will fail with EHOSTUNREACH */ |
| 51 | +---- |
| 52 | + |
| 53 | + |
| 54 | +== SEE ALSO |
| 55 | +* xref:zmq_connect_peer.adoc[zmq_connect_peer] |
| 56 | +* xref:zmq_disconnect.adoc[zmq_disconnect] |
| 57 | +* xref:zmq_msg_routing_id.adoc[zmq_msg_routing_id] |
| 58 | +* xref:zmq_msg_set_routing_id.adoc[zmq_msg_set_routing_id] |
| 59 | +* xref:zmq_socket.adoc[zmq_socket] |
| 60 | +* xref:zmq.adoc[zmq] |
| 61 | + |
| 62 | + |
| 63 | +== AUTHORS |
| 64 | +This page was written by the 0MQ community. To make a change please |
| 65 | +read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>. |
| 66 | + |
| 67 | + |
0 commit comments