Skip to content

Commit

Permalink
Permits bind error from IPv6 port binding request
Browse files Browse the repository at this point in the history
  • Loading branch information
mscottford committed Aug 25, 2023
1 parent 5f9b707 commit 6cd1d01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .semver
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
:major: 0
:minor: 6
:patch: 2
:special: 'dev'
:patch: 3
:special: ''
:metadata: ''
10 changes: 7 additions & 3 deletions lib/corgibytes/freshli/commons/test_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6cd1d01

Please sign in to comment.