@@ -217,7 +217,10 @@ module.exports.getKeepAliveProbes = function getKeepAliveProbes(socket) {
217
217
/**
218
218
* Sets the TCP_USER_TIMEOUT value for specified socket.
219
219
*
220
- * Note: The msec will be rounded towards the closest integer
220
+ * Notes:
221
+ * * This method is only supported on `linux`, will throw on `darwin` and `freebsd`.
222
+ * * The msec will be rounded towards the closest integer.
223
+ *
221
224
*
222
225
* @since v1.4.0
223
226
* @param {Net.Socket } socket to set the value for
@@ -229,19 +232,21 @@ module.exports.getKeepAliveProbes = function getKeepAliveProbes(socket) {
229
232
* NetKeepAlive.setUserTimeout(s, 30000)
230
233
*
231
234
* @throws {AssertionError } setUserTimeout requires two arguments
235
+ * @throws {AssertionError } setUserTimeout called on unsupported platform
232
236
* @throws {AssertionError } setUserTimeout expects an instance of socket as its first argument
233
237
* @throws {AssertionError } setUserTimeout requires msec to be a Number
234
238
* @throws {ErrnoException|Error } Unexpected error
235
239
*/
236
- module . exports . setUserTimeout = function setUserTimeout (
237
- socket ,
238
- msecs
239
- ) {
240
+ module . exports . setUserTimeout = function setUserTimeout ( socket , msecs ) {
240
241
Assert . strictEqual (
241
242
arguments . length ,
242
243
2 ,
243
244
'setUserTimeout requires two arguments'
244
245
)
246
+ Assert (
247
+ Constants . TCP_USER_TIMEOUT != null ,
248
+ 'setUserTimeout called on unsupported platform'
249
+ )
245
250
Assert (
246
251
_isSocket ( socket ) ,
247
252
'setUserTimeout expects an instance of socket as its first argument'
@@ -269,6 +274,8 @@ module.exports.setUserTimeout = function setUserTimeout(
269
274
/**
270
275
* Returns the TCP_USER_TIMEOUT value for specified socket.
271
276
*
277
+ * Note: This method is only supported on `linux`, will throw on `darwin` and `freebsd`.
278
+ *
272
279
* @since v1.4.0
273
280
* @param {Net.Socket } socket to check the value for
274
281
*
@@ -278,6 +285,7 @@ module.exports.setUserTimeout = function setUserTimeout(
278
285
* NetKeepAlive.getUserTimeout(s) // returns 30000 based on setter example
279
286
*
280
287
* @throws {AssertionError } getUserTimeout requires one arguments
288
+ * @throws {AssertionError } getUserTimeout called on unsupported platform
281
289
* @throws {AssertionError } getUserTimeout expects an instance of socket as its first argument
282
290
* @throws {ErrnoException|Error } Unexpected error
283
291
*/
@@ -287,6 +295,10 @@ module.exports.getUserTimeout = function getUserTimeout(socket) {
287
295
1 ,
288
296
'getUserTimeout requires one arguments'
289
297
)
298
+ Assert (
299
+ Constants . TCP_USER_TIMEOUT != null ,
300
+ 'getUserTimeout called on unsupported platform'
301
+ )
290
302
Assert (
291
303
_isSocket ( socket ) ,
292
304
'getUserTimeout expects an instance of socket as its first argument'
0 commit comments