Tokio Listen Helpers
Status: Beta
Documentation | Github | Crate
A library that allows to listen network sockets with proper resource limits and error handling.
Basic challenges:
- Some connection accept errors (like "connection reset") must be ignored, some (like "too many files open") may consume 100% CPU when ignored. You need to know what to do with them every time
- Server must accept connections up to a certain limit to avoid DoS attacks
- Shutting down listener and update the set of addresses listened should be obvious to implement
Example
Here is the basic example:
let TIME_TO WAIT_ON_ERROR = from_millis;
let MAX_SIMULTANEOUS_CONNECTIONS = 1000;
let mut lp = new.unwrap;
let listener = bind.unwrap;
lp.run.unwrap; // stream doesn't end in this case
License
Licensed under either of
- Apache License, Version 2.0, (./LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (./LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.