[][src]Function libzmq::proxy

pub fn proxy<F, B>(frontend: F, backend: B) -> Result<(), Error> where
    F: GetRawSocket,
    B: GetRawSocket, 

Start a built-in ØMQ proxy between a frontend and a backend socket.

The two sockets must be configured before creating the proxy.

The proxy connects a frontend socket to a backend socket. Conceptually, data flows from frontend to backend. Depending on the socket types, replies may flow in the opposite direction. The direction is conceptual only; the proxy is fully symmetric and there is no technical difference between frontend and backend.

Returned Errors

Example

use libzmq::{prelude::*, *};
use std::thread;

let radio_addr: InprocAddr = "frontend".try_into()?;
let dish_addr: InprocAddr = "backend".try_into()?;
let group: Group = "some group".try_into()?;

let radio = RadioBuilder::new()
    .bind(&radio_addr)
    .build()?;

let frontend = DishBuilder::new()
    .connect(&radio_addr)
    .join(&group)
    .build()?;

let backend = RadioBuilder::new()
    .bind(&dish_addr)
    .build()?;

let dish = DishBuilder::new()
    .connect(&dish_addr)
    .join(&group)
    .build()?;

let proxy_handle = thread::spawn(move || proxy(frontend, backend));

let mut msg = Msg::new();
msg.set_group(&group);
radio.send(msg)?;

let msg = dish.recv_msg()?;
assert!(msg.is_empty());