-
-
Notifications
You must be signed in to change notification settings - Fork 37.1k
Provide an easy way to get all net.Server connections #48433
Copy link
Copy link
Closed as not planned
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.netIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
Description
Activity
Metadata
Metadata
Assignees
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.netIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
What is the problem this feature will solve?
Currently, there seems no way to get all
net.Serverconnections 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 triedfor (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