# Examples
Run any example with:
```sh
cargo run --example <name>
```
Examples are numbered by topic so you can work through them in order.
## 01 — Request / Reply
| `01_req_rep_server` | `01_req_rep_client` | REP socket — receives messages and echoes a reply |
| `01_req_rep_client` | `01_req_rep_server` | REQ socket — sends 10 messages and prints replies |
| `01_req_rep_client_opts` | `01_req_rep_server` | REQ socket configured via `SocketBuilder` (peer identity) |
## 02 — Multipart Messages
| `02_multipart_server` | `02_multipart_client` | REP socket handling multipart messages |
| `02_multipart_client` | `02_multipart_server` | REQ socket sending multipart messages |
## 03 — Broker (ROUTER / DEALER)
| `03_broker_server` | ROUTER+DEALER proxy using `rustzmq2::proxy()` — routes between two sets of peers |
## 04 — Publish / Subscribe
| `04_pubsub_server` | `04_pubsub_client` | PUB socket broadcasting weather updates |
| `04_pubsub_client` | `04_pubsub_server` | SUB socket — subscribes and prints 10 messages |
## 05 — Topic Filtering
| `05_topics_server` | `05_topics_client` | PUB socket sending multipart stock ticker messages |
| `05_topics_client` | `05_topics_server` | SUB socket filtering by stock ticker prefix |
## 06 — XPUB / XSUB
| `06_xpub_server` | `04_pubsub_client` | XPUB socket — single socket, interleaves publishing with subscription event tracking |
| `06_xsub_forwarder` | `04_pubsub_server`, `06_xsub_forwarder_client` | PUB → XSUB+XPUB → SUB forwarder (proxy device) |
| `06_xsub_forwarder_client` | `04_pubsub_server`, `06_xsub_forwarder` | SUB socket connecting through the forwarder |
## 07 — Pipeline (PUSH / PULL)
| `07_pipeline_ventilator` | `07_pipeline_worker`, `07_pipeline_sink` | PUSH socket distributing 100 work items |
| `07_pipeline_worker` | `07_pipeline_ventilator` | PULL+PUSH worker — simulates work with a sleep |
| `07_pipeline_sink` | `07_pipeline_worker` | PULL socket collecting results and reporting total time |
| `07_pipeline_forwarder` | — | DEALER↔DEALER forwarder using `rustzmq2::proxy()` |
## 08 — Scatter / Gather
| `08_scatter_gather_scatter` | `08_scatter_gather_gather` | SCATTER socket distributing 20 jobs round-robin |
| `08_scatter_gather_gather` | `08_scatter_gather_scatter` | GATHER socket receiving distributed jobs |
## 09 — Pair
| `09_pair` | PAIR socket — exclusive one-to-one bidirectional channel (both sides in one process) |
## 10 — Security: PLAIN
| `10_security_plain` | PLAIN credentials + ZAP handler that validates username/password |
## 11 — Security: CURVE
| `11_security_curve` | CURVE mutual authentication and end-to-end encryption |
## Notes
- Examples 01–09 use the `async_helpers` shim so they work with both the `tokio`
and `smol` feature flags. Examples 06, 09, 10, and 11 use `#[tokio::main]`
directly and require the `tokio` feature (default).
- IPC examples require a Unix system and the `ipc` feature (on by default).
- Security examples (10, 11) require the `curve` feature for CURVE support.