mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-07-14 13:25: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)
|
public bool Connect(string serverName, SMBTransportType transport)
|
||||||
{
|
{
|
||||||
IPHostEntry hostEntry = Dns.GetHostEntry(serverName);
|
IPAddress[] hostAddresses = Dns.GetHostAddresses(serverName);
|
||||||
if (hostEntry.AddressList.Length == 0)
|
if (hostAddresses.Length == 0)
|
||||||
{
|
{
|
||||||
throw new Exception(String.Format("Cannot resolve host name {0} to an IP address", serverName));
|
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);
|
return Connect(serverAddress, transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,12 +66,12 @@ namespace SMBLibrary.Client
|
||||||
public bool Connect(string serverName, SMBTransportType transport)
|
public bool Connect(string serverName, SMBTransportType transport)
|
||||||
{
|
{
|
||||||
m_serverName = serverName;
|
m_serverName = serverName;
|
||||||
IPHostEntry hostEntry = Dns.GetHostEntry(serverName);
|
IPAddress[] hostAddresses = Dns.GetHostAddresses(serverName);
|
||||||
if (hostEntry.AddressList.Length == 0)
|
if (hostAddresses.Length == 0)
|
||||||
{
|
{
|
||||||
throw new Exception(String.Format("Cannot resolve host name {0} to an IP address", serverName));
|
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);
|
return Connect(serverAddress, transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue