win_wait_for: fix local port check on port not accessible externally (#37093)

* win_wait_for: use loopback IP instead of hostname if 127.0.0.1 is used (#36762)

* win_wait_for: use loopback IP instead of hostname if 127.0.0.1 is used

* removed reverse dns lookup in port check

(cherry picked from commit 67ffde4ac1)

* Added changelog for win_wait_for local port fix
pull/37094/head
Jordan Borean 7 years ago committed by GitHub
parent f0a808e02c
commit 33773624fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- win_wait_for - fixed issue when trying to check a localport when the port is not available externally

@ -54,17 +54,9 @@ if ($port -ne $null) {
}
Function Test-Port($hostname, $port) {
# try and resolve the IP/Host, if it fails then just use the host passed in
try {
$resolve_hostname = ([System.Net.Dns]::GetHostEntry($hostname)).HostName
} catch {
# oh well just use the IP addres
$resolve_hostname = $hostname
}
$timeout = $connect_timeout * 1000
$socket = New-Object -TypeName System.Net.Sockets.TcpClient
$connect = $socket.BeginConnect($resolve_hostname, $port, $null, $null)
$connect = $socket.BeginConnect($hostname, $port, $null, $null)
$wait = $connect.AsyncWaitHandle.WaitOne($timeout, $false)
if ($wait) {

Loading…
Cancel
Save