Skip to content

Provide an easy way to get all net.Server connections #48433

Closed as not planned
Closed as not planned
@qiulang

Description

@qiulang

What is the problem this feature will solve?

Currently, there seems no way to get all net.Server connections with the public API.

net.server.getConnections((err, count) => {...}) only returns the count of the connection, I can't get each connection within its callback. I tried for (let socket of server.connections) {...} inside the callback, and got the error TypeError: server.connections is not iterable.

I have to store each socket myself on Event: 'connection' callback, keep an array of those socket objects.

What is the feature you are proposing to solve the problem?

Inside net.server.getConnections((err, count) => {...}) callback, in addition to returning connection count, also return all the connections.

What alternatives have you considered?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.netIssues and PRs related to the net subsystem.stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions