From a0e7b9983cf54151e8b11d4899f5c667152b8b8d Mon Sep 17 00:00:00 2001 From: theanarkh Date: Sat, 9 Jul 2022 20:00:18 +0800 Subject: [PATCH] net: add drop event for net server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/43582 Reviewed-By: Paolo Insogna Reviewed-By: Matteo Collina Reviewed-By: Juan José Arboleda --- doc/api/net.md | 17 ++++++++++++ lib/net.js | 20 ++++++++++++++ .../test-net-server-drop-connections.js | 26 +++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 test/parallel/test-net-server-drop-connections.js diff --git a/doc/api/net.md b/doc/api/net.md index 2785e6e7a38d21..cd4d388524d422 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -281,6 +281,23 @@ added: v0.1.90 Emitted when the server has been bound after calling [`server.listen()`][]. +### Event: `'drop'` + + + +When the number of connections reaches the threshold of `server.maxConnections`, +the server will drop new connections and emit `'drop'` event instead. If it is a +TCP server, the argument is as follows, otherwise the argument is `undefined`. + +* `data` {Object} The argument passed to event listener. + * `localAddress` {string} Local address. + * `localPort` {number} Local port. + * `remoteAddress` {string} Remote address. + * `remotePort` {number} Remote port. + * `remoteFamily` {string} Remote IP family. `'IPv4'` or `'IPv6'`. + ### `server.address()`