-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: add local address/port for better errors
Adds localAddress and localPort to req so we have better error messages. Also fixes a case where ex is used before it is declared. PR-URL: #3946 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- Loading branch information
Showing
2 changed files
with
22 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const net = require('net'); | ||
|
||
var client = net.connect({ | ||
port: common.PORT + 1, | ||
localPort: common.PORT, | ||
localAddress: common.localhostIPv4 | ||
}); | ||
|
||
client.on('error', common.mustCall(function onError(err) { | ||
assert.equal(err.localPort, common.PORT); | ||
assert.equal(err.localAddress, common.localhostIPv4); | ||
})); |