File tree Expand file tree Collapse file tree 1 file changed +9
-15
lines changed 
module/PowerShellEditorServices Expand file tree Collapse file tree 1 file changed +9
-15
lines changed Original file line number Diff line number Diff line change @@ -176,21 +176,15 @@ function Test-PortAvailability {
176176    $portAvailable  =  $true 
177177
178178    try  {
179-         if  ($isPS5orLater ) {
180-             $ipAddresses  =  [System.Net.Dns ]::GetHostEntryAsync(" localhost" 
181-         }
182-         else  {
183-             $ipAddresses  =  [System.Net.Dns ]::GetHostEntry(" localhost" 
184-         }
185- 
186-         foreach  ($ipAddress  in  $ipAddresses )
187-         {
188-             Log " Testing availability of port ${PortNumber}  at address ${ipAddress}  / $ ( $ipAddress.AddressFamily  ) " 
189- 
190-             $tcpListener  =  New-Object  System.Net.Sockets.TcpListener @ ($ipAddress ,  $PortNumber )
191-             $tcpListener.Start  ()
192-             $tcpListener.Stop  ()
193-         }
179+         #  After some research, I don't believe we should run into problems using an IPv4 port
180+         #  that happens to be in use via an IPv6 address.  That is based on this info:
181+         #  https://www.ibm.com/support/knowledgecenter/ssw_i5_54/rzai2/rzai2compipv4ipv6.htm#rzai2compipv4ipv6__compports
182+         $ipAddress  =  [System.Net.IPAddress ]::Loopback
183+         Log " Testing availability of port ${PortNumber}  at address ${ipAddress}  / $ ( $ipAddress.AddressFamily  ) " 
184+ 
185+         $tcpListener  =  New-Object  System.Net.Sockets.TcpListener @ ($ipAddress ,  $PortNumber )
186+         $tcpListener.Start  ()
187+         $tcpListener.Stop  ()
194188    }
195189    catch  [System.Net.Sockets.SocketException ] {
196190        $portAvailable  =  $false 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments