// Auto-generated by scripts/gen_parity_tests.py from docs/runtime-parity.md.
// Module: node:net
// This file is a byte-for-byte parity test against `node --experimental-strip-types`.
// Edit the TODO lines below to exercise each API; rerun
// `./run_parity_tests.sh --filter test_parity_net` to verify.

import * as net from "node:net";


// ── Functions ──
// PERRY-SKIP: net.connect requires live connection (non-deterministic).
// PERRY-SKIP: net.connect(path) requires live IPC endpoint.
// PERRY-SKIP: net.connect(port,host) requires live connection.
// PERRY-SKIP: net.createConnection requires live connection.
// PERRY-SKIP: net.createConnection(path) requires live IPC endpoint.
// PERRY-SKIP: net.createConnection(port,host) requires live connection.
// PERRY-SKIP: net.createServer() — codegen 'expression NetCreateServer not yet supported'.
console.log("net.isIP('127.0.0.1'):", net.isIP("127.0.0.1"));
console.log("net.isIP('::1'):", net.isIP("::1"));
console.log("net.isIP('not-ip'):", net.isIP("not-ip"));
console.log("net.isIPv4('127.0.0.1'):", net.isIPv4("127.0.0.1"));
console.log("net.isIPv4('::1'):", net.isIPv4("::1"));
console.log("net.isIPv6('::1'):", net.isIPv6("::1"));
console.log("net.isIPv6('127.0.0.1'):", net.isIPv6("127.0.0.1"));
console.log("net.getDefaultAutoSelectFamily():", net.getDefaultAutoSelectFamily());
try {
  net.setDefaultAutoSelectFamily(net.getDefaultAutoSelectFamily());
  console.log("net.setDefaultAutoSelectFamily: ok");
} catch (e) {
  console.log("net.setDefaultAutoSelectFamily error:", (e as Error).message);
}
console.log("net.getDefaultAutoSelectFamilyAttemptTimeout():", net.getDefaultAutoSelectFamilyAttemptTimeout());
try {
  net.setDefaultAutoSelectFamilyAttemptTimeout(net.getDefaultAutoSelectFamilyAttemptTimeout());
  console.log("net.setDefaultAutoSelectFamilyAttemptTimeout: ok");
} catch (e) {
  console.log("net.setDefaultAutoSelectFamilyAttemptTimeout error:", (e as Error).message);
}

// ── Classes ──
console.log("class net.BlockList typeof:", typeof net.BlockList);
try {
  const bl = new net.BlockList();
  console.log("new net.BlockList typeof:", typeof bl);
  bl.addAddress("127.0.0.1");
  console.log("blockList.addAddress: ok");
  bl.addRange("10.0.0.1", "10.0.0.10");
  console.log("blockList.addRange: ok");
  bl.addSubnet("192.168.0.0", 16);
  console.log("blockList.addSubnet: ok");
  console.log("blockList.check('127.0.0.1'):", bl.check("127.0.0.1"));
  console.log("blockList.check('8.8.8.8'):", bl.check("8.8.8.8"));
  // PERRY-SKIP: blockList.fromJSON — not a method on instances in Node (static-ish, version-dependent).
  const rulesJson = bl.toJSON();
  console.log("blockList.toJSON isArray:", Array.isArray(rulesJson));
  console.log("blockList.rules isArray:", Array.isArray(bl.rules));
  console.log("BlockList.isBlockList(bl):", net.BlockList.isBlockList(bl));
  console.log("BlockList.isBlockList({}):", net.BlockList.isBlockList({}));
} catch (e) {
  console.log("BlockList error:", (e as Error).message);
}
console.log("class net.SocketAddress typeof:", typeof net.SocketAddress);
try {
  const sa = new net.SocketAddress({ address: "127.0.0.1", port: 0, family: "ipv4" });
  console.log("new net.SocketAddress typeof:", typeof sa);
  console.log("socketAddress.address:", sa.address);
  console.log("socketAddress.family:", sa.family);
  console.log("socketAddress.flowlabel typeof:", typeof sa.flowlabel);
  console.log("socketAddress.port:", sa.port);
  const parsed = net.SocketAddress.parse("127.0.0.1:80");
  console.log("SocketAddress.parse typeof:", typeof parsed);
} catch (e) {
  console.log("SocketAddress error:", (e as Error).message);
}
console.log("class net.Server typeof:", typeof net.Server);
try {
  const s = new net.Server();
  console.log("new net.Server typeof:", typeof s);
  console.log("server.address() before listen:", s.address());
  console.log("server.close typeof:", typeof s.close);
  console.log("server.getConnections typeof:", typeof s.getConnections);
  console.log("server.listen typeof:", typeof s.listen);
  console.log("server.ref typeof:", typeof s.ref);
  console.log("server.unref typeof:", typeof s.unref);
  console.log("server[Symbol.asyncDispose] typeof:", typeof s[Symbol.asyncDispose]);
  console.log("server.listening:", s.listening);
  console.log("server.maxConnections typeof:", typeof s.maxConnections);
  console.log("server.dropMaxConnection typeof:", typeof (s as any).dropMaxConnection);
  s.close();
} catch (e) {
  console.log("Server error:", (e as Error).message);
}
console.log("class net.Socket typeof:", typeof net.Socket);
try {
  const sock = new net.Socket();
  console.log("new net.Socket typeof:", typeof sock);
  console.log("socket.address typeof:", typeof sock.address);
  console.log("socket.connect typeof:", typeof sock.connect);
  console.log("socket.destroy typeof:", typeof sock.destroy);
  console.log("socket.destroySoon typeof:", typeof sock.destroySoon);
  console.log("socket.end typeof:", typeof sock.end);
  console.log("socket.pause typeof:", typeof sock.pause);
  console.log("socket.ref typeof:", typeof sock.ref);
  console.log("socket.resetAndDestroy typeof:", typeof sock.resetAndDestroy);
  console.log("socket.resume typeof:", typeof sock.resume);
  console.log("socket.setEncoding typeof:", typeof sock.setEncoding);
  console.log("socket.setKeepAlive typeof:", typeof sock.setKeepAlive);
  console.log("socket.setNoDelay typeof:", typeof sock.setNoDelay);
  console.log("socket.setTimeout typeof:", typeof sock.setTimeout);
  console.log("socket.getTypeOfService typeof:", typeof (sock as any).getTypeOfService);
  console.log("socket.setTypeOfService typeof:", typeof (sock as any).setTypeOfService);
  console.log("socket.unref typeof:", typeof sock.unref);
  console.log("socket.write typeof:", typeof sock.write);
  console.log("socket.autoSelectFamilyAttemptedAddresses isArray:", Array.isArray(sock.autoSelectFamilyAttemptedAddresses));
  console.log("socket.bufferSize:", sock.bufferSize);
  console.log("socket.bytesRead:", sock.bytesRead);
  console.log("socket.bytesWritten typeof:", typeof sock.bytesWritten);
  console.log("socket.connecting:", sock.connecting);
  console.log("socket.destroyed:", sock.destroyed);
  console.log("socket.localAddress typeof:", typeof sock.localAddress);
  console.log("socket.localPort typeof:", typeof sock.localPort);
  console.log("socket.localFamily typeof:", typeof sock.localFamily);
  console.log("socket.pending:", sock.pending);
  console.log("socket.remoteAddress typeof:", typeof sock.remoteAddress);
  console.log("socket.remoteFamily typeof:", typeof sock.remoteFamily);
  console.log("socket.remotePort typeof:", typeof sock.remotePort);
  console.log("socket.readyState:", sock.readyState);
  console.log("socket.timeout typeof:", typeof sock.timeout);
  sock.destroy();
} catch (e) {
  console.log("Socket error:", (e as Error).message);
}

// Coverage: 2 auto-emitted, 80 TODO, 0 skip-listed.
