# OpcClassicDiscoveryClient Members

> Reference: Represents a client which discovers the OPC Classic servers registered on a host.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcClassicDiscoveryClient</a></dd>
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx.client.classic">Opc.UaFx.Client.Classic</a></dd>
<dt>Assembly</dt>
<dd>Opc.UaFx.Advanced.dll</dd>
<dt>Package</dt>
<dd>Opc.UaFx.Advanced v2.59.0</dd>
</dl>

## Constructors

### OpcClassicDiscoveryClient

<span class="api-meta">3 overloads</span>

| Overload | Description |
|---|---|
| [OpcClassicDiscoveryClient()](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/members#opcclassicdiscoveryclient-noparams) | Initializes a new instance of the [OpcClassicDiscoveryClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/) class which discovers the servers on the local host. |
| [OpcClassicDiscoveryClient(string)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/members#opcclassicdiscoveryclient-system-string) | Initializes a new instance of the [OpcClassicDiscoveryClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/) class using the `host` specified. |
| [OpcClassicDiscoveryClient(string, OpcClassicIdentity)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/members#opcclassicdiscoveryclient-system-string-opc-uafx-classic-opcclassicidentity)<span class="api-meta">since v2.12</span> | Initializes a new instance of the [OpcClassicDiscoveryClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/) class using the `host` and `hostIdentity` specified. |

**Exceptions (all overloads)**

| Exception | Condition |
|---|---|
| [OpcException](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/) | Connecting to the host failed; for more details see exception details. |

#### OpcClassicDiscoveryClient()

Initializes a new instance of the [OpcClassicDiscoveryClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/) class which discovers the servers on the local host.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcClassicDiscoveryClient()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub New()
```

</div>

#### OpcClassicDiscoveryClient(string)

Initializes a new instance of the [OpcClassicDiscoveryClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/) class using the `host` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcClassicDiscoveryClient(string host)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub New(host As String)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `host` | [String](https://learn.microsoft.com/dotnet/api/system.string) | The name or address of the host whose servers are to be discovered. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The `host` is an empty string. |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `host` is a null reference (Nothing in Visual Basic). |

#### OpcClassicDiscoveryClient(string, OpcClassicIdentity)

<span class="api-meta">since v2.12</span>

Initializes a new instance of the [OpcClassicDiscoveryClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/) class using the `host` and `hostIdentity` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcClassicDiscoveryClient(string host, OpcClassicIdentity hostIdentity)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub New(host As String, hostIdentity As OpcClassicIdentity)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `host` | [String](https://learn.microsoft.com/dotnet/api/system.string) | The name or address of the host whose servers are to be discovered. |
| `hostIdentity` | [OpcClassicIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicidentity/) | The [OpcClassicIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicidentity/) to use to connect to the host or a null reference (Nothing in Visual Basic) to connect without an explicit identity. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The `host` is an empty string. |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `host` is a null reference (Nothing in Visual Basic). |

## Properties

### Host

Gets the name or address of the host whose servers are discovered.

<div class="api-signature" data-lang="csharp">

```csharp
public string Host { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property Host As String
```

</div>

**Property value**

[String](https://learn.microsoft.com/dotnet/api/system.string)

The host specified when the [OpcClassicDiscoveryClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/) was created; "localhost" if none was specified.

### HostIdentity

<span class="api-meta">since v2.12</span>

Gets the identity used to connect to the host.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcClassicIdentity HostIdentity { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property HostIdentity As OpcClassicIdentity
```

</div>

**Property value**

[OpcClassicIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicidentity/)

The [OpcClassicIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicidentity/) specified when the [OpcClassicDiscoveryClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/) was created or a null reference (Nothing in Visual Basic) if the client connects without an explicit identity.

## Methods

### Close

Closes the connection to the host.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcStatus Close()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function Close() As OpcStatus
```

</div>

**Returns**

[OpcStatus](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatus/)

An [OpcStatus](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatus/) with the code [Good](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#good) if the connection has been closed; otherwise with the code [Bad](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#bad).

**Remarks**

The method does not throw an exception in case closing the connection fails.

### DiscoverEndpoints

Discovers the endpoints of the servers on the host for all OPC Classic interfaces known.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcClassicEndpointDescriptionCollection DiscoverEndpoints()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function DiscoverEndpoints() As OpcClassicEndpointDescriptionCollection
```

</div>

**Returns**

[OpcClassicEndpointDescriptionCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicendpointdescriptioncollection/)

An [OpcClassicEndpointDescriptionCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicendpointdescriptioncollection/) with one description per server. The [Interfaces](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicendpointdescription/members#interfaces) of a description provide the interfaces the server has been discovered with.

**Exceptions**

| Exception | Condition |
|---|---|
| [OpcException](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/) | Discovering the servers failed; for more details see exception details. |

### DiscoverServers

<span class="api-meta">3 overloads</span>

| Overload | Description |
|---|---|
| [DiscoverServers()](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/members#discoverservers-noparams) | Discovers the servers on the host which implement the OPC Classic specification AE 1.0, DA 1.0, DA 2.0, DA 3.0 or HDA 1.0. |
| [DiscoverServers(IEnumerable&lt;OpcClassicInterface&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/members#discoverservers-system-collections-generic-ienumerable-of-opc-uafx-classic-opcclassicinterface) | Discovers the servers on the host which implement one of the `interfaceSpecifications` specified. |
| [DiscoverServers(params OpcClassicInterface\[\])](#discoverservers-opc-uafx-classic-opcclassicinterface-array) | Discovers the servers on the host which implement one of the `interfaceSpecifications` specified. |

**Exceptions (all overloads)**

| Exception | Condition |
|---|---|
| [OpcException](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/) | Discovering the servers failed; for more details see exception details. |

#### DiscoverServers()

Discovers the servers on the host which implement the OPC Classic specification AE 1.0, DA 1.0, DA 2.0, DA 3.0 or HDA 1.0.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcClassicApplicationDescriptionCollection DiscoverServers()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function DiscoverServers() As OpcClassicApplicationDescriptionCollection
```

</div>

**Returns**

[OpcClassicApplicationDescriptionCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicapplicationdescriptioncollection/)

An [OpcClassicApplicationDescriptionCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicapplicationdescriptioncollection/) with a description of each server discovered.

#### DiscoverServers(IEnumerable&lt;OpcClassicInterface&gt;)

Discovers the servers on the host which implement one of the `interfaceSpecifications` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcClassicApplicationDescriptionCollection DiscoverServers(
    IEnumerable<OpcClassicInterface> interfaceSpecifications)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function DiscoverServers(
    interfaceSpecifications As IEnumerable(Of OpcClassicInterface)) As OpcClassicApplicationDescriptionCollection
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `interfaceSpecifications` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[OpcClassicInterface](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicinterface/)&gt; | A sequence of the [OpcClassicInterface](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicinterface/) instances of the interfaces the servers have to implement. |

**Returns**

[OpcClassicApplicationDescriptionCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicapplicationdescriptioncollection/)

An [OpcClassicApplicationDescriptionCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicapplicationdescriptioncollection/) with a description of each server discovered.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `interfaceSpecifications` sequence or one of its items is a null reference (Nothing in Visual Basic). |

**Remarks**

In case the `interfaceSpecifications` sequence is empty, the servers which implement the OPC Classic specification AE 1.0, DA 1.0, DA 2.0, DA 3.0 or HDA 1.0 are discovered. A server whose URI does not state a valid class identifier is not included in the result.

#### DiscoverServers(params OpcClassicInterface\[\])

Discovers the servers on the host which implement one of the `interfaceSpecifications` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcClassicApplicationDescriptionCollection DiscoverServers(
    params OpcClassicInterface[] interfaceSpecifications)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function DiscoverServers(
    ParamArray interfaceSpecifications As OpcClassicInterface()) As OpcClassicApplicationDescriptionCollection
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `interfaceSpecifications` | params [OpcClassicInterface](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicinterface/)[] | An array of the [OpcClassicInterface](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicinterface/) instances of the interfaces the servers have to implement. |

**Returns**

[OpcClassicApplicationDescriptionCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicapplicationdescriptioncollection/)

An [OpcClassicApplicationDescriptionCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.classic.opcclassicapplicationdescriptioncollection/) with a description of each server discovered.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `interfaceSpecifications` array or one of its items is a null reference (Nothing in Visual Basic). |

**Remarks**

In case the `interfaceSpecifications` array is empty, the servers which implement the OPC Classic specification AE 1.0, DA 1.0, DA 2.0, DA 3.0 or HDA 1.0 are discovered. A server whose URI does not state a valid class identifier is not included in the result.

### Dispose

<span class="api-meta">2 overloads</span>

| Overload | Description |
|---|---|
| [Dispose()](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/members#dispose-noparams) | Releases all resources used by the [OpcClassicDiscoveryClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/). |
| [Dispose(bool)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/members#dispose-system-boolean)<span class="api-meta">protected · virtual</span> | Releases the unmanaged resources used by the [OpcClassicDiscoveryClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/) and optionally releases the managed resources. |

#### Dispose()

Releases all resources used by the [OpcClassicDiscoveryClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/).

<div class="api-signature" data-lang="csharp">

```csharp
public void Dispose()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub Dispose()
```

</div>

**Implements**

[Dispose()](https://learn.microsoft.com/dotnet/api/system.idisposable.dispose)

#### Dispose(bool)

<span class="api-meta">protected · virtual</span>

Releases the unmanaged resources used by the [OpcClassicDiscoveryClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.classic.opcclassicdiscoveryclient/) and optionally releases the managed resources.

<div class="api-signature" data-lang="csharp">

```csharp
protected virtual void Dispose(bool disposing)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Protected Overridable Sub Dispose(disposing As Boolean)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `disposing` | [Boolean](https://learn.microsoft.com/dotnet/api/system.boolean) | The value true to release both managed and unmanaged resources; otherwise the value false to release only unmanaged resources. |
