import type { PortManager } from './types'; /** * Check if a port is in use */ export declare function isPortInUse(port: number, hostname: string, verbose?: boolean): Promise; /** * Find next available port */ export declare function findAvailablePort(startPort: number, hostname: string, verbose?: boolean, maxAttempts?: number): Promise; /** * Test if a port is actually connectable, i.e. whether *something* is already * listening there and accepting connections. * * This answers "is this port occupied and healthy", which is the opposite of * what a caller looking for a port to BIND wants - see {@link isPortClaimable}. */ export declare function testPortConnectivity(port: number, hostname: string, timeout?: number, verbose?: boolean): Promise; /** * Test whether *we* can claim `port`: bind a probe listener on it, dial that * listener, and confirm the bytes that come back are the probe's own nonce. * * Binding alone is not proof of ownership. On macOS a wildcard bind succeeds * while a loopback-only listener already holds the same port (Postgres on * 127.0.0.1:5432 is the everyday example), and the more specific binding keeps * winning every connection - so a server "successfully" bound there would never * receive a request. The nonce handshake is what distinguishes the two: traffic * has to reach our listener, not somebody else's. */ export declare function isPortClaimable(port: number, hostname: string, timeout?: number, verbose?: boolean): Promise; // Global port manager instance export declare const portManager: DefaultPortManager; export declare class DefaultPortManager implements PortManager { usedPorts: Set; constructor(hostname?: string, verbose?: boolean, maxRetries?: number); getNextAvailablePort(startPort: number, verifyClaim?: boolean): Promise; releasePort(port: number): void; }