You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/integration/targets/win_wait_for/templates/http-server.ps1

23 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()
}