Skip to content

Only check ipv4 addresses for port availlability during PSES startup #1281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions scripts/Start-EditorServices.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,15 @@ function Test-PortAvailability {
$portAvailable = $true

try {
if ($isPS5orLater) {
$ipAddresses = [System.Net.Dns]::GetHostEntryAsync("localhost").Result.AddressList
}
else {
$ipAddresses = [System.Net.Dns]::GetHostEntry("localhost").AddressList
}

foreach ($ipAddress in $ipAddresses)
{
Log "Testing availability of port ${PortNumber} at address ${ipAddress} / $($ipAddress.AddressFamily)"

$tcpListener = New-Object System.Net.Sockets.TcpListener @($ipAddress, $PortNumber)
$tcpListener.Start()
$tcpListener.Stop()
}
# After some research, I don't believe we should run into problems using an IPv4 port
# that happens to be in use via an IPv6 address. That is based on this info:
# https://www.ibm.com/support/knowledgecenter/ssw_i5_54/rzai2/rzai2compipv4ipv6.htm#rzai2compipv4ipv6__compports
$ipAddress = [System.Net.IPAddress]::Loopback
Log "Testing availability of port ${PortNumber} at address ${ipAddress} / $($ipAddress.AddressFamily)"

$tcpListener = New-Object System.Net.Sockets.TcpListener @($ipAddress, $PortNumber)
$tcpListener.Start()
$tcpListener.Stop()
}
catch [System.Net.Sockets.SocketException] {
$portAvailable = $false
Expand Down