* Checks to see if the port is in use by creating a server on that port if a localhost or alias * or try to connect to an existing server. * * If we think it is a localhost, It tries to make sure it and its aliases are all free. For * instance 0.0.0.0, 127.0.0.1, ::1 are true al
(port: number, _host: string)
| 95 | * @param host host ip address to use. Ignored. All loopback addresses are checked |
| 96 | */ |
| 97 | public static isPortInUseEx(port: number, _host: string): Promise<boolean> { |
| 98 | const tries = TcpPortScanner.getLocalHostAliases(); |
| 99 | const promises = tries.map((host) => TcpPortScanner.isPortInUse(port, host)); |
| 100 | |
| 101 | return new Promise(async (resolve, reject) => { |
| 102 | const results = await Promise.all(promises.map(p => p.then(x => x).catch(e => e))); |
| 103 | ConsoleLog(`isPortInUseEx: Results ${results}`); |
| 104 | for (const r of results) { |
| 105 | if (r !== false) { |
| 106 | resolve(true); |
| 107 | return; |
| 108 | } |
| 109 | resolve(false); |
| 110 | } |
| 111 | }); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Scan for free ports (no one listening) on the specified host. |
no test coverage detected