xref: /third_party/node/test/sequential/test-net-localport.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/sequential/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ciconst net = require('net');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst server = net.createServer(function(socket) {
71cb0ef41Sopenharmony_ci  assert.strictEqual(socket.remotePort, common.PORT);
81cb0ef41Sopenharmony_ci  socket.end();
91cb0ef41Sopenharmony_ci  socket.on('close', function() {
101cb0ef41Sopenharmony_ci    server.close();
111cb0ef41Sopenharmony_ci  });
121cb0ef41Sopenharmony_ci}).listen(0).on('listening', function() {
131cb0ef41Sopenharmony_ci  const client = net.connect({
141cb0ef41Sopenharmony_ci    host: '127.0.0.1',
151cb0ef41Sopenharmony_ci    port: this.address().port,
161cb0ef41Sopenharmony_ci    localPort: common.PORT,
171cb0ef41Sopenharmony_ci  }).on('connect', function() {
181cb0ef41Sopenharmony_ci    assert.strictEqual(client.localPort, common.PORT);
191cb0ef41Sopenharmony_ci  });
201cb0ef41Sopenharmony_ci});
21

Indexes created Thu Nov 07 10:32:03 CST 2024