Skip to content

Instantly share code, notes, and snippets.

@altrive
Created March 29, 2014 16:48
Show Gist options
  • Save altrive/9857839 to your computer and use it in GitHub Desktop.
Save altrive/9857839 to your computer and use it in GitHub Desktop.
param (
$RequestUrl = "http://127.0.0.1"
)
function Main
{
$ErrorActionPreference = "Stop"
Add-Type -AssemblyName System.Net.Http
#Get ServicedPoint
$servicePoint = [Net.ServicePointManager]::FindServicePoint($RequestUrl)
$servicePoint.ConnectionLimit = 24
#Create HttpClient and reuse connection if available
$client = New-Object Net.Http.HttpClient
#$client.DefaultRequestHeaders.ConnectionClose = $true
foreach ($i in 1..10)
{
$task = $client.GetAsync($RequestUrl)
#sleep -Milliseconds 100
#$task.Wait()
}
#Opened port is retained about 100 sec
foreach ($i in 0..120)
{
Write-Host ("Current Connection Count: {0} ,Elapsed {1} seconds" -f $servicePoint.CurrentConnections, $i)
sleep 1
}
}
Main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment