| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 40c8e6d commit d615757
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,35 +12,29 @@ if (common.inFreeBSDJail) { | |||
| 12 | 12 | var conns = 0; | |
| 13 | 13 | var clientLocalPorts = []; | |
| 14 | 14 | var serverRemotePorts = []; | |
| 15 | - | ||
| 16 | - const server = net.createServer(function(socket) { | ||
| 15 | + const client = new net.Socket(); | ||
| 16 | + const server = net.createServer(socket => { | ||
| 17 | 17 | serverRemotePorts.push(socket.remotePort); | |
| 18 | - testConnect(); | ||
| 18 | + socket.end(); | ||
| 19 | 19 | }); | |
| 20 | 20 | ||
| 21 | - const client = new net.Socket(); | ||
| 22 | - | ||
| 23 | - server.on('close', common.mustCall(function() { | ||
| 21 | + server.on('close', common.mustCall(() => { | ||
| 24 | 22 | assert.deepEqual(clientLocalPorts, serverRemotePorts, | |
| 25 | 23 | 'client and server should agree on the ports used'); | |
| 26 | - assert.equal(2, conns); | ||
| 24 | + assert.strictEqual(2, conns); | ||
| 27 | 25 | })); | |
| 28 | 26 | ||
| 29 | - server.listen(common.PORT, common.localhostIPv4, testConnect); | ||
| 27 | + server.listen(common.PORT, common.localhostIPv4, connect); | ||
| 30 | 28 | ||
| 31 | - function testConnect() { | ||
| 32 | - if (conns > serverRemotePorts.length || conns > clientLocalPorts.length) { | ||
| 33 | - // We're waiting for a callback to fire. | ||
| 29 | + function connect() { | ||
| 30 | + if (conns === 2) { | ||
| 31 | + server.close(); | ||
| 34 | 32 | return; | |
| 35 | 33 | } | |
| 36 | 34 | ||
| 37 | - if (conns === 2) { | ||
| 38 | - return server.close(); | ||
| 39 | - } | ||
| 40 | - client.connect(common.PORT, common.localhostIPv4, function() { | ||
| 41 | - clientLocalPorts.push(this.localPort); | ||
| 42 | - this.once('close', testConnect); | ||
| 43 | - this.destroy(); | ||
| 44 | - }); | ||
| 45 | 35 | conns++; | |
| 36 | + client.once('close', connect); | ||
| 37 | + client.connect(common.PORT, common.localhostIPv4, () => { | ||
| 38 | + clientLocalPorts.push(client.localPort); | ||
| 39 | + }); | ||
| 46 | 40 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments