Closed miketang84 closed 9 years ago
This is just a result of oversimplification in the example, since it doesn't deregister interest in the socket once it's done writing the response and doesn't track its own status. You could easily modify the handler to remove interest in mio::event::WRITABLE
after the response has been written.
I'll see if I can spend some time rewriting the example to be idiomatic and correctly track interest etc.
@daogangtang The easiest thing to do is to just poll with Interest::writable()
and PollOpt::edge() + PollOpt::oneshot()
so that you receive only one writable notification on the stream and can write the RESPONSE
once before deregistering/closing the connection.
That's not really a robust approach to general tcp communication though, but anything more is out-of-scope for this crate, but isn't for rust-aio
, for instance.
hi, I ran your tcp.rs example,
I visit 127.0.0.1:3000 using telnet, I found that this example write RESPONSE forever, why? this is not my want. I want after I send a msg, it response once. What should I do?
Thank you.