diff --git a/SMBLibrary/Client/SMB1Client.cs b/SMBLibrary/Client/SMB1Client.cs index 7eb1efa..3301a86 100644 --- a/SMBLibrary/Client/SMB1Client.cs +++ b/SMBLibrary/Client/SMB1Client.cs @@ -60,12 +60,12 @@ namespace SMBLibrary.Client public bool Connect(string serverName, SMBTransportType transport) { - IPHostEntry hostEntry = Dns.GetHostEntry(serverName); - if (hostEntry.AddressList.Length == 0) + IPAddress[] hostAddresses = Dns.GetHostAddresses(serverName); + if (hostAddresses.Length == 0) { throw new Exception(String.Format("Cannot resolve host name {0} to an IP address", serverName)); } - IPAddress serverAddress = hostEntry.AddressList[0]; + IPAddress serverAddress = hostAddresses[0]; return Connect(serverAddress, transport); } diff --git a/SMBLibrary/Client/SMB2Client.cs b/SMBLibrary/Client/SMB2Client.cs index b64f42b..887a689 100644 --- a/SMBLibrary/Client/SMB2Client.cs +++ b/SMBLibrary/Client/SMB2Client.cs @@ -66,12 +66,12 @@ namespace SMBLibrary.Client public bool Connect(string serverName, SMBTransportType transport) { m_serverName = serverName; - IPHostEntry hostEntry = Dns.GetHostEntry(serverName); - if (hostEntry.AddressList.Length == 0) + IPAddress[] hostAddresses = Dns.GetHostAddresses(serverName); + if (hostAddresses.Length == 0) { throw new Exception(String.Format("Cannot resolve host name {0} to an IP address", serverName)); } - IPAddress serverAddress = hostEntry.AddressList[0]; + IPAddress serverAddress = hostAddresses[0]; return Connect(serverAddress, transport); }