/
githubmirror
/
deno
Обзор
Документация
Войти
/
githubmirror
/
deno
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
tests/specs/node/net_socket_fd/main.ts
33 строки
1 KB
Nathan Whitaker
refactor(ext/node): use native LibUvStreamWrap based Wrap's to reduce code duplication (#33301)
17 апр 2026, 08:18
Не верифицирован
17 апр 2026, 08:18
7529c84
Код
Авторство
О чём код?
// Test net.Socket({ fd }) with a pipe created via child_process. // This verifies that creating a Socket from a raw fd works through // the full stack: _createHandle -> Pipe.open(fd) -> PipeWrap. import { createRequire } from "node:module"; const require = createRequire(import.meta.url); const { execSync } = require("child_process"); // Create a socketpair via a helper subprocess const result = execSync( `${Deno.execPath()} eval " const net = require('net'); const server = net.createServer((conn) => { conn.write('hello from socket fd'); conn.end(); }); const tmpSock = require('path').join(require('os').tmpdir(), 'deno_net_socket_fd_test_' + process.pid + '.sock'); try { require('fs').unlinkSync(tmpSock); } catch {} server.listen(tmpSock, () => { const client = net.connect(tmpSock, () => { let data = ''; client.on('data', (chunk) => data += chunk); client.on('end', () => { console.log(data); server.close(); try { require('fs').unlinkSync(tmpSock); } catch {} }); }); }); "`, { encoding: "utf8" }, ); console.log("result:", result.trim());