mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-08-04 06:51:50 +02:00
SMB2Client: Add ability to control response timeout (#232)
* SMB2Client Timeout Config & Exception * Revert gitignore * Revert TimeoutException
This commit is contained in:
parent
660442e778
commit
45dbf282fb
1 changed files with 12 additions and 2 deletions
|
@ -66,6 +66,11 @@ namespace SMBLibrary.Client
|
|||
/// with a specific host name associated with the cluster and is not accessible using the node IP address or node host name.
|
||||
/// </param>
|
||||
public bool Connect(string serverName, SMBTransportType transport)
|
||||
{
|
||||
return Connect(serverName, transport, DefaultResponseTimeoutInMilliseconds);
|
||||
}
|
||||
|
||||
public bool Connect(string serverName, SMBTransportType transport, int responseTimeoutInMilliseconds)
|
||||
{
|
||||
m_serverName = serverName;
|
||||
IPAddress[] hostAddresses = Dns.GetHostAddresses(serverName);
|
||||
|
@ -74,13 +79,18 @@ namespace SMBLibrary.Client
|
|||
throw new Exception(String.Format("Cannot resolve host name {0} to an IP address", serverName));
|
||||
}
|
||||
IPAddress serverAddress = IPAddressHelper.SelectAddressPreferIPv4(hostAddresses);
|
||||
return Connect(serverAddress, transport);
|
||||
return Connect(serverAddress, transport, responseTimeoutInMilliseconds);
|
||||
}
|
||||
|
||||
public bool Connect(IPAddress serverAddress, SMBTransportType transport)
|
||||
{
|
||||
return Connect(serverAddress, transport, DefaultResponseTimeoutInMilliseconds);
|
||||
}
|
||||
|
||||
public bool Connect(IPAddress serverAddress, SMBTransportType transport, int responseTimeoutInMilliseconds)
|
||||
{
|
||||
int port = (transport == SMBTransportType.DirectTCPTransport ? DirectTCPPort : NetBiosOverTCPPort);
|
||||
return Connect(serverAddress, transport, port, DefaultResponseTimeoutInMilliseconds);
|
||||
return Connect(serverAddress, transport, port, responseTimeoutInMilliseconds);
|
||||
}
|
||||
|
||||
private bool Connect(IPAddress serverAddress, SMBTransportType transport, int port, int responseTimeoutInMilliseconds)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue