From 6cd1d01e99558f75be433580414c47405930ffcf Mon Sep 17 00:00:00 2001 From: "M. Scott Ford" Date: Fri, 25 Aug 2023 16:55:45 -0400 Subject: [PATCH] Permits bind error from IPv6 port binding request --- .semver | 4 ++-- lib/corgibytes/freshli/commons/test_services.rb | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.semver b/.semver index 34e9dc8..c6e9859 100644 --- a/.semver +++ b/.semver @@ -1,6 +1,6 @@ --- :major: 0 :minor: 6 -:patch: 2 -:special: 'dev' +:patch: 3 +:special: '' :metadata: '' diff --git a/lib/corgibytes/freshli/commons/test_services.rb b/lib/corgibytes/freshli/commons/test_services.rb index e8770e9..763868a 100644 --- a/lib/corgibytes/freshli/commons/test_services.rb +++ b/lib/corgibytes/freshli/commons/test_services.rb @@ -19,9 +19,13 @@ def start_on(port) socket4 = Socket.new(Socket::Constants::AF_INET, Socket::Constants::SOCK_STREAM, 0) socket4.bind(Socket.pack_sockaddr_in(port, '0.0.0.0')) - # bind to a socket using both ipv4 and ipv6 - socket6 = Socket.new(Socket::Constants::AF_INET6, Socket::Constants::SOCK_STREAM, 0) - socket6.bind(Socket.pack_sockaddr_in(port, '::')) + begin + # bind to a socket using both ipv4 and ipv6 + socket6 = Socket.new(Socket::Constants::AF_INET6, Socket::Constants::SOCK_STREAM, 0) + socket6.bind(Socket.pack_sockaddr_in(port, '::')) + rescue Errno::EADDRINUSE + # if ipv6 is not available, then just use ipv4 + end @test_services[port] = { v4: socket4, v6: socket6 } end