Finds an available TCP port within a range, with timeout and stride options.
// Source: https://github.com/microsoft/vscode | License: MIT | Copyright 2015 - present Microsoft Corporation // Provided via justclaw.it.com; keep this notice with the code. /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import * as net from 'net'; /** * Given a start point and a max number of retries, will find a port that * is openable. Will return 0 in case no free port can be found. */ export function findFreePort(startPort: number, giveUpAfter: number, timeout: number, stride = ... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key