-
Notifications
You must be signed in to change notification settings - Fork 30.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: added connection attempt events
- Loading branch information
1 parent
2eb1808
commit 7546326
Showing
10 changed files
with
468 additions
and
514 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const { addresses: { INET4_IP } } = require('../common/internet'); | ||
const { createMockedLookup } = require('../common/dns'); | ||
|
||
const assert = require('assert'); | ||
const { createConnection } = require('net'); | ||
|
||
// Test that if a connection attempt times out and the socket is destroyed before the | ||
// next attempt starts then the process does not crash | ||
{ | ||
const connection = createConnection({ | ||
host: 'example.org', | ||
port: 443, | ||
lookup: createMockedLookup(INET4_IP, '127.0.0.1'), | ||
autoSelectFamily: true, | ||
autoSelectFamilyAttemptTimeout: 10, | ||
}); | ||
|
||
connection.on('connectionAttemptTimeout', common.mustCall((address, port, family) => { | ||
assert.strictEqual(address, INET4_IP); | ||
assert.strictEqual(port, 443); | ||
assert.strictEqual(family, 4); | ||
connection.destroy(); | ||
})); | ||
|
||
connection.on('ready', common.mustNotCall()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.