mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-07 00:00:09 +02:00
update comment and simplify echo example
This commit is contained in:
+4
-7
@@ -26,16 +26,13 @@ fn main() {
|
||||
println!("Listening on: {}", addr);
|
||||
|
||||
// Pull out the stream of incoming connections and then for each new
|
||||
// one spin up a new task copying data. We put the `socket` into a
|
||||
// `Arc` structure which then allows us to share it across the
|
||||
// read/write halves with a small shim.
|
||||
// one spin up a new task copying data.
|
||||
//
|
||||
// Finally we use the `io::copy` future to copy all data from the
|
||||
// We use the `io::copy` future to copy all data from the
|
||||
// reading half onto the writing half.
|
||||
socket.incoming().for_each(|(socket, addr)| {
|
||||
let socket = futures::lazy(|| futures::finished(TaskIo::new(socket)));
|
||||
let pair = socket.map(|s| s.split());
|
||||
let amt = pair.and_then(|(reader, writer)| copy(reader, writer));
|
||||
let (reader, writer) = TaskIo::new(socket).split();
|
||||
let amt = copy(reader, writer);
|
||||
|
||||
// Once all that is done we print out how much we wrote, and then
|
||||
// critically we *forget* this future which allows it to run
|
||||
|
||||
Reference in New Issue
Block a user