Skip to content

Commit 83b91cc

Browse files
authored
Only check ipv4 addresses for port availlability during PSES startup (#1281)
Fix #603 where system has ipv6 addresses disabled. This is also more consistent with the PSES TCP listener which always [IPAddress]::Loopback as the IP address.
1 parent 335acd3 commit 83b91cc

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

scripts/Start-EditorServices.ps1

+9-15
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,15 @@ function Test-PortAvailability {
171171
$portAvailable = $true
172172

173173
try {
174-
if ($isPS5orLater) {
175-
$ipAddresses = [System.Net.Dns]::GetHostEntryAsync("localhost").Result.AddressList
176-
}
177-
else {
178-
$ipAddresses = [System.Net.Dns]::GetHostEntry("localhost").AddressList
179-
}
180-
181-
foreach ($ipAddress in $ipAddresses)
182-
{
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()
188-
}
174+
# After some research, I don't believe we should run into problems using an IPv4 port
175+
# that happens to be in use via an IPv6 address. That is based on this info:
176+
# https://www.ibm.com/support/knowledgecenter/ssw_i5_54/rzai2/rzai2compipv4ipv6.htm#rzai2compipv4ipv6__compports
177+
$ipAddress = [System.Net.IPAddress]::Loopback
178+
Log "Testing availability of port ${PortNumber} at address ${ipAddress} / $($ipAddress.AddressFamily)"
179+
180+
$tcpListener = New-Object System.Net.Sockets.TcpListener @($ipAddress, $PortNumber)
181+
$tcpListener.Start()
182+
$tcpListener.Stop()
189183
}
190184
catch [System.Net.Sockets.SocketException] {
191185
$portAvailable = $false

0 commit comments

Comments
 (0)