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.
Listener which simplifies using TcpListener