Skip to content

Separate the action of starting a TCP listener from the action of waiting to accept the first incoming connection. #8689

Closed
@anasazi

Description

@anasazi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions