Created
          March 29, 2014 16:48 
        
      - 
      
 - 
        
Save altrive/9857839 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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