Description
Currently we do not start listening on a TCP socket until we call .accept() for the first time (at which point we block until there is an incoming connection). This makes it difficult to test TCP code in a multithreaded environment since we cannot guarantee that the server is up and running before attempting to connect without having the client spin on connection attempts.
I would like to move to this alternative interface:
TcpListener.listen() consumes the TcpListener and returns a TcpAcceptor.
TcpAcceptor.accept() replicates the current behavior of TcpListener.accept() (blocks and returns a Result).
TcpAcceptor will implement Iterator and produce an infinite stream of incoming connections.
The socket will be closed when the TcpAcceptor goes out of scope.
The libuv listener takes the backlog size as a parameter. Currently, we hardcode this to 128, but we could make it a argument of TcpListener.listen() and provide a default.