1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/win_wait_for/templates/http-server.ps1

23 lines
571 B
PowerShell
Raw Normal View History

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