This repository was archived by the owner on Aug 29, 2023. It is now read-only.
File tree 3 files changed +12
-3
lines changed
3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,12 @@ export interface TCPOptions {
36
36
*/
37
37
maxConnections ?: number
38
38
39
+ /**
40
+ * Parameter to specify the maximum length of the queue of pending connections
41
+ * https://nodejs.org/dist/latest-v18.x/docs/api/net.html#serverlisten
42
+ */
43
+ backlog ?: number
44
+
39
45
/**
40
46
* Close server (stop listening for new connections) if connections exceed a limit.
41
47
* Open server (start listening for new connections) if connections fall below a limit.
@@ -215,6 +221,7 @@ class TCP implements Transport {
215
221
return new TCPListener ( {
216
222
...options ,
217
223
maxConnections : this . opts . maxConnections ,
224
+ backlog : this . opts . backlog ,
218
225
closeServerOnMaxConnections : this . opts . closeServerOnMaxConnections ,
219
226
socketInactivityTimeout : this . opts . inboundSocketInactivityTimeout ,
220
227
socketCloseTimeout : this . opts . socketCloseTimeout ,
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ interface Context extends TCPCreateListenerOptions {
41
41
socketInactivityTimeout ?: number
42
42
socketCloseTimeout ?: number
43
43
maxConnections ?: number
44
+ backlog ?: number
44
45
metrics ?: Metrics
45
46
closeServerOnMaxConnections ?: CloseServerOnMaxConnectionsOpts
46
47
}
@@ -269,12 +270,13 @@ export class TCPListener extends EventEmitter<ListenerEvents> implements Listene
269
270
270
271
const peerId = ma . getPeerId ( )
271
272
const listeningAddr = peerId == null ? ma . decapsulateCode ( CODE_P2P ) : ma
273
+ const { backlog } = this . context
272
274
273
275
this . status = {
274
276
started : true ,
275
277
listeningAddr,
276
278
peerId,
277
- netConfig : multiaddrToNetConfig ( listeningAddr )
279
+ netConfig : multiaddrToNetConfig ( listeningAddr , { backlog } )
278
280
}
279
281
280
282
await this . netListen ( )
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ const ProtoFamily = { ip4: 'IPv4', ip6: 'IPv6' }
8
8
9
9
export type NetConfig = ListenOptions | ( IpcSocketConnectOpts & TcpSocketConnectOpts )
10
10
11
- export function multiaddrToNetConfig ( addr : Multiaddr ) : NetConfig {
11
+ export function multiaddrToNetConfig ( addr : Multiaddr , config : NetConfig = { } ) : NetConfig {
12
12
const listenPath = addr . getPath ( )
13
13
14
14
// unix socket listening
@@ -22,7 +22,7 @@ export function multiaddrToNetConfig (addr: Multiaddr): NetConfig {
22
22
}
23
23
24
24
// tcp listening
25
- return addr . toOptions ( )
25
+ return { ... addr . toOptions ( ) , ... config }
26
26
}
27
27
28
28
export function getMultiaddrs ( proto : 'ip4' | 'ip6' , ip : string , port : number ) : Multiaddr [ ] {
You can’t perform that action at this time.
0 commit comments