mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
Simply echo example: split() can now happen on the main task.
This commit is contained in:
parent
614887b8c1
commit
556143b7c6
@ -48,8 +48,8 @@ fn main() {
|
|||||||
// 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.
|
// reading half onto the writing half.
|
||||||
let done = socket.incoming().for_each(move |(socket, addr)| {
|
let done = socket.incoming().for_each(move |(socket, addr)| {
|
||||||
let pair = futures::lazy(|| futures::finished(socket.split()));
|
let (reader, writer) = socket.split();
|
||||||
let amt = pair.and_then(|(reader, writer)| copy(reader, writer));
|
let amt = copy(reader, writer);
|
||||||
|
|
||||||
// Once all that is done we print out how much we wrote, and then
|
// Once all that is done we print out how much we wrote, and then
|
||||||
// critically we *spawn* this future which allows it to run
|
// critically we *spawn* this future which allows it to run
|
||||||
|
Loading…
x
Reference in New Issue
Block a user