.NET Based OPC UA Client/Server SDK  3.1.0.500
Discovery – Find Servers

Table of Contents

Description

The following dialog shows an example implementation of the method Find Servers. Press the button “Show Code” to display the corresponding code, and the button “Help” to show this documentation page.

clienttutorials_find_servers.png

The method Find Servers can be used to connect to a running Local Discovery Server. Enter the host name of the Local Discovery Server into the input field “Host Name” at “Find Servers Request” and press the button “Find Servers”. Then all discovered servers are listed at “Find Servers Response”. Check the box in front of “Use Asynchronous Pattern” to call “BeginFindServer” instead of “FindServer”.

Note
A Local Discovery Server must be running and at least one server should be registered.

See Local Discovery for more information about Local Discovery Servers and FindServers OPC UA service.

Sample Code

The following code connects to the Local Discovery Server running on a given host and lists all discovered servers in the output window.

First an instance of the Discovery class is created. This class provides helper functionality that is needed to find servers. In the next step, the URL of the local discovery server is created. The standard port is 4840. Finally we can call FindServers.

List<ApplicationDescription> servers;
// create the object used to find servers or endpoints.
using (Discovery discovery = new Discovery(m_parent.Application))
{
// look for the LDS with the default endpoint.
string discoveryUrl = "opc.tcp://" + HostNameTB.Text + ":4840";
servers = discovery.FindServers(discoveryUrl);
}