From 2e15df57614c411c2c6b3a5ef708ba9c62f3d0a1 Mon Sep 17 00:00:00 2001 From: theanarkh Date: Mon, 27 Jun 2022 02:02:41 +0800 Subject: [PATCH] net: add drop event for net server --- doc/api/net.md | 20 ++++++++++++++ lib/net.js | 19 ++++++++++++++ .../test-net-server-drop-connections.js | 26 +++++++++++++++++++ 3 files changed, 65 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 e0858e314f4ae7..ec9b84c6d09d0b 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -281,6 +281,26 @@ 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 arguments is as follow, otherwise return `undefined`. + +```json +{ + "localAddress": "::ffff:127.0.0.1", + "localPort": 61054, + "remoteAddress": "::ffff:127.0.0.1", + "remotePort": 61060, + "remoteFamily": "IPv6" +} +``` + ### `server.address()`