mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-07-14 05:15:03 +02:00
Fixes bug when trying to use local ip address as host name. (#133)
This commit is contained in:
parent
5c4b88c759
commit
f8baa1b101
2 changed files with 6 additions and 6 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue