From 54900936b639923f96973ae60e79ff11345023e3 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Mon, 10 Oct 2016 16:21:17 +0200 Subject: [PATCH] [System.Data] Use same socket family for data receiver as it has its client. Fixes #44624 --- .../System.Data/System.Data.SqlClient/SqlConnection.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs index 415f5832e86..f7248acb6bc 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs @@ -930,7 +930,11 @@ namespace System.Data.SqlClient if (Client.Available <= 0) return -1; // Error - IPEndPoint endpoint = new IPEndPoint (Dns.GetHostEntry ("localhost").AddressList [0], 0); + + IPEndPoint endpoint = CreateLocalEndpoint (); + if (endpoint == null) + return -1; + Byte [] rawrs; rawrs = Receive (ref endpoint); @@ -955,6 +959,16 @@ namespace System.Data.SqlClient return SqlServerTcpPort; } + + IPEndPoint CreateLocalEndpoint () + { + foreach (var addr in Dns.GetHostEntry ("localhost").AddressList) { + if (addr.AddressFamily == Client.AddressFamily) + return new IPEndPoint (addr, 0); + } + + return null; + } } struct ColumnInfo -- 2.11.4.GIT