Hi all,
I want to create list of futures or stream from list of connection address, but I couln't figure out how can I use tokio
and futures
to do this, here is a sample pseudo code:
fn main() {
let srv_list = vec![
"127.0.0.1:12345",
"127.0.0.1:12346",
"127.0.0.1:12347",
"127.0.0.1:12348",
"127.0.0.1:12349",
];
let conn_fut: Stream<Item = (), Error = ()> = srv_list.iter().map(|addr| {
let addr = addr.parse().unwrap();
TcpStream::connect(&addr).and_then(|stream| {
println!("connected to address: {:?}", addr);
Ok(())
})
.map_err(|err| {
println!("couldn't connect, {:?}", err);
})
}).collect();