[−][src]Function ductile::connect_channel
pub fn connect_channel<A: ToSocketAddrs, S, R>(
addr: A
) -> Result<(ChannelSender<S>, ChannelReceiver<R>)>
Connect to a remote channel.
All the remote channels are full-duplex, therefore this function returns a channel for sending the message and a channel from where receive them.
This function will no enable message encryption.
let port = 18455; // let's hope we can bind this port! let mut server = ChannelServer::<(), _>::bind(("127.0.0.1", port)).unwrap(); let client_thread = std::thread::spawn(move || { let (sender, receiver) = connect_channel::<_, _, ()>(("127.0.0.1", port)).unwrap(); sender.send(vec![1, 2, 3, 4]).unwrap(); }); let (sender, receiver, _addr) = server.next().unwrap(); let data: Vec<i32> = receiver.recv().unwrap(); assert_eq!(data, vec![1, 2, 3, 4]);