2 releases
0.1.1 | Oct 25, 2021 |
---|---|
0.1.0 | Sep 4, 2019 |
#7 in #tcp-listener
9KB
100 lines
Purpose
nblistener makes it easier to interact with std::net::TcpListener.
Look at the documentation for usage examples.
lib.rs
:
nblistener
nblistener provides the Listener trait to simplify interactions with TcpListener.
std::net::TcpListener does not provide a simple interface to stop handling connections once the incoming() method is invoked.
Listener provides enough support to allow a listening socket to be closed from another thread in a fairly re-active fashion.
It does this by wrapping a non-blocking TcpListener which sleeps for a user specified duration (10ms is a good choice) when the listener would otherwise block.
This is not the highest performance or most efficient way to solve this kind of problem, but the interface is fairly ergonomic and may help out anyone who is struggling to use TcpListener and wants something simple to support testing or low throughput usage.
Dependencies
~220KB