@@ -1188,19 +1188,22 @@ sub get_free_port
1188
1188
# Check to see if anything else is listening on this TCP port.
1189
1189
# Seek a port available for all possible listen_addresses values,
1190
1190
# so callers can harness this port for the widest range of purposes.
1191
- # The 0.0.0.0 test achieves that for post-2006 Cygwin, which
1192
- # automatically sets SO_EXCLUSIVEADDRUSE. The same holds for MSYS (a
1193
- # Cygwin fork). Testing 0.0.0.0 is insufficient for Windows native
1194
- # Perl (https://stackoverflow.com/a/14388707), so we also test
1195
- # individual addresses.
1191
+ # The 0.0.0.0 test achieves that for MSYS, which automatically sets
1192
+ # SO_EXCLUSIVEADDRUSE. Testing 0.0.0.0 is insufficient for Windows
1193
+ # native Perl (https://stackoverflow.com/a/14388707), so we also
1194
+ # have to test individual addresses. Doing that for 127.0.0/24
1195
+ # addresses other than 127.0.0.1 might fail with EADDRNOTAVAIL on
1196
+ # non-Linux, non-Windows kernels.
1196
1197
#
1197
- # On non-Linux, non-Windows kernels, binding to 127.0.0/24 addresses
1198
- # other than 127.0.0.1 might fail with EADDRNOTAVAIL. Binding to
1199
- # 0.0.0.0 is unnecessary on non-Windows systems.
1198
+ # Thus, 0.0.0.0 and individual 127.0.0/24 addresses are tested
1199
+ # only on Windows and only when TCP usage is requested.
1200
1200
if ($found == 1)
1201
1201
{
1202
1202
foreach my $addr (qw( 127.0.0.1) ,
1203
- $use_tcp ? qw( 127.0.0.2 127.0.0.3 0.0.0.0) : ())
1203
+ $use_tcp ? qw( 127.0.0.2 127.0.0.3 0.0.0.0) : ())
1204
+ $use_tcp && $TestLib::windows_os
1205
+ ? qw( 127.0.0.2 127.0.0.3 0.0.0.0)
1206
+ : ())
1204
1207
{
1205
1208
if (!can_bind($addr , $port ))
1206
1209
{
0 commit comments