"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-824c4c46a288b839f13b24022655329c2aeb9f81/node_modules-@microsoft-dev-tunnels-ssh-tcp-tcpListenerFactory.js.map