ansible/test/integration/targets/win_wait_for/templates/http-server.ps1
Jordan Borean 9b7dbc78c3 win_wait_for: added module (#26556)
* win_wait_for: added module

* Increased timeout on async task

* added more debug messages for test debug

* revert to using win_shell instead of win_command

* rebased from master and updated copyright string

* Updated metadata version

* Capitalised start of short_description

* disabled win_wait_for tests until async issues are solved
2017-08-22 15:02:07 -04:00

22 lines
571 B
PowerShell

$ErrorActionPreference = 'Stop'
$port = {{test_win_wait_for_port}}
$endpoint = New-Object -TypeName System.Net.IPEndPoint([System.Net.IPAddress]::Parse("0.0.0.0"), $port)
$listener = New-Object -TypeName System.Net.Sockets.TcpListener($endpoint)
$listener.Server.ReceiveTimeout = 3000
$listener.Start()
try {
while ($true) {
if (-not $listener.Pending()) {
Start-Sleep -Seconds 1
} else {
$client = $listener.AcceptTcpClient()
$client.Close()
break
}
}
} finally {
$listener.Stop()
}