"use strict";
//
//  Copyright (c) Microsoft Corporation. All rights reserved.
//
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultTcpListenerFactory = void 0;
const net = require("net");
class DefaultTcpListenerFactory {
    async createTcpListener(remotePort, localIPAddress, localPort, canChangeLocalPort, cancellation) {
        if (!localIPAddress)
            throw new TypeError('Local IP address is required.');
        if (!Number.isInteger(localPort) || localPort < 0)
            throw new TypeError('Local port must be a non-negative integer.');
        const listener = net.createServer();
        await new Promise((resolve, reject) => {
            listener.listen({
                host: localIPAddress,
                port: localPort,
                ipv6Only: net.isIPv6(localIPAddress),
                exclusive: false,
            });
            listener.on('listening', resolve);
            listener.on('error', reject);
        });
        return listener;
    }
}
exports.DefaultTcpListenerFactory = DefaultTcpListenerFactory;
//# sourceMappingURL=https://github.com/VSCodium/sourcemaps/releases/download/stable-4c0b0c6cc561d2d3636d1ec250935431876ce4dc/node_modules-@microsoft-dev-tunnels-ssh-tcp-tcpListenerFactory.js.map