connect(socketPath: string,timeoutMs: number): Promise<net.Socket | null>
Attempts a connection to the given path (POSIX socket or Windows named pipe).
Resolves the connected socket on success, null on any failure (peer absent,
ECONNREFUSED, ENOENT, timeout). Lets net.createConnection produce the error
directly — a pre-emptive existsSync check would not work for Windows named
pipes (they live in \\.\pipe\..., not on the regular filesystem).
import * as Socket from './socket.ts'; // Defined, not invoked: dials a Unix socket / named pipe. async function dialDaemon() { return await Socket.connect('/tmp/qunitx-daemon-ab12cd34ef56.sock', 1_000); // net.Socket, or null }