xref: /third_party/node/test/parallel/test-net-socket-ready-without-cb.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ci// This test ensures that socket.connect can be called without callback
51cb0ef41Sopenharmony_ci// which is optional.
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst net = require('net');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst server = net.createServer(common.mustCall(function(conn) {
101cb0ef41Sopenharmony_ci  conn.end();
111cb0ef41Sopenharmony_ci  server.close();
121cb0ef41Sopenharmony_ci})).listen(0, 'localhost', common.mustCall(function() {
131cb0ef41Sopenharmony_ci  const client = new net.Socket();
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci  client.on('ready', common.mustCall(function() {
161cb0ef41Sopenharmony_ci    client.end();
171cb0ef41Sopenharmony_ci  }));
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci  client.connect(server.address());
201cb0ef41Sopenharmony_ci}));
21

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