diff --git a/spec/std/http/server/server_spec.cr b/spec/std/http/server/server_spec.cr index 3c634d755abf..ce8e76f9a11e 100644 --- a/spec/std/http/server/server_spec.cr +++ b/spec/std/http/server/server_spec.cr @@ -18,7 +18,7 @@ private def unix_request(path) end private def unused_port - TCPServer.open(0) do |server| + TCPServer.open(Socket::IPAddress::UNSPECIFIED, 0) do |server| server.local_address.port end end diff --git a/spec/std/openssl/ssl/server_spec.cr b/spec/std/openssl/ssl/server_spec.cr index 8618ed780a50..d2cc41efe88b 100644 --- a/spec/std/openssl/ssl/server_spec.cr +++ b/spec/std/openssl/ssl/server_spec.cr @@ -11,7 +11,7 @@ require "../../../support/ssl" describe OpenSSL::SSL::Server do it "sync_close" do - TCPServer.open(0) do |tcp_server| + TCPServer.open(Socket::IPAddress::UNSPECIFIED, 0) do |tcp_server| context = OpenSSL::SSL::Context::Server.new ssl_server = OpenSSL::SSL::Server.new(tcp_server, context) @@ -22,7 +22,7 @@ describe OpenSSL::SSL::Server do end it "don't sync_close" do - TCPServer.open(0) do |tcp_server| + TCPServer.open(Socket::IPAddress::UNSPECIFIED, 0) do |tcp_server| context = OpenSSL::SSL::Context::Server.new ssl_server = OpenSSL::SSL::Server.new(tcp_server, context, sync_close: false) ssl_server.context.should eq context @@ -35,7 +35,7 @@ describe OpenSSL::SSL::Server do it ".new" do context = OpenSSL::SSL::Context::Server.new - TCPServer.open(0) do |tcp_server| + TCPServer.open(Socket::IPAddress::UNSPECIFIED, 0) do |tcp_server| ssl_server = OpenSSL::SSL::Server.new tcp_server, context, sync_close: false ssl_server.context.should eq context @@ -46,7 +46,7 @@ describe OpenSSL::SSL::Server do it ".open" do context = OpenSSL::SSL::Context::Server.new - TCPServer.open(0) do |tcp_server| + TCPServer.open(Socket::IPAddress::UNSPECIFIED, 0) do |tcp_server| ssl_server = nil OpenSSL::SSL::Server.open tcp_server, context do |server| server.wrapped.should eq tcp_server diff --git a/spec/std/socket/spec_helper.cr b/spec/std/socket/spec_helper.cr index 486e4a142ee7..276e2f4195f2 100644 --- a/spec/std/socket/spec_helper.cr +++ b/spec/std/socket/spec_helper.cr @@ -5,7 +5,7 @@ module SocketSpecHelper class_getter?(supports_ipv6 : Bool) do TCPServer.open("::1", 0) { return true } false - rescue Socket::BindError + rescue Socket::Error false end end @@ -33,7 +33,7 @@ def each_ip_family(&block : Socket::Family, String, String ->) end def unused_local_port - TCPServer.open("::", 0) do |server| + TCPServer.open(Socket::IPAddress::UNSPECIFIED, 0) do |server| server.local_address.port end end diff --git a/spec/std/socket/tcp_server_spec.cr b/spec/std/socket/tcp_server_spec.cr index a7d85b8edeff..451cbbb33d61 100644 --- a/spec/std/socket/tcp_server_spec.cr +++ b/spec/std/socket/tcp_server_spec.cr @@ -120,7 +120,7 @@ describe TCPServer, tags: "network" do it "binds to all interfaces" do port = unused_local_port - TCPServer.open(port) do |server| + TCPServer.open(Socket::IPAddress::UNSPECIFIED, port) do |server| server.local_address.port.should eq port end end diff --git a/spec/std/socket/tcp_socket_spec.cr b/spec/std/socket/tcp_socket_spec.cr index b7a22882ec0f..b44b3a9729f6 100644 --- a/spec/std/socket/tcp_socket_spec.cr +++ b/spec/std/socket/tcp_socket_spec.cr @@ -112,6 +112,8 @@ describe TCPSocket, tags: "network" do end it "fails to connect IPv6 to IPv4 server" do + pending! "IPv6 is unavailable" unless SocketSpecHelper.supports_ipv6? + port = unused_local_port TCPServer.open("0.0.0.0", port) do |server| @@ -133,7 +135,7 @@ describe TCPSocket, tags: "network" do it "sync from server" do port = unused_local_port - TCPServer.open("::", port) do |server| + TCPServer.open(Socket::IPAddress::UNSPECIFIED, port) do |server| TCPSocket.open("localhost", port) do |client| sock = server.accept sock.sync?.should eq(server.sync?) @@ -152,7 +154,7 @@ describe TCPSocket, tags: "network" do it "settings" do port = unused_local_port - TCPServer.open("::", port) do |server| + TCPServer.open(Socket::IPAddress::UNSPECIFIED, port) do |server| TCPSocket.open("localhost", port) do |client| # test protocol specific socket options (client.tcp_nodelay = true).should be_true @@ -202,7 +204,7 @@ describe TCPSocket, tags: "network" do channel = Channel(Exception?).new spawn do - TCPServer.open("::", port) do |server| + TCPServer.open(Socket::IPAddress::UNSPECIFIED, port) do |server| channel.send nil sock = server.accept sock.read_timeout = 3.second