FindServerOnNetwork

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

Moderator: uasdkcpp

Post Reply
samsa123
Jr. Member
Jr. Member
Posts: 2
Joined: 02 Nov 2017, 11:39

FindServerOnNetwork

Post by samsa123 »

hi,

is there a example code that uses the findServersOnNetwork instead of the findservers? im not that experienced in this so if anybody could help me that would be great!

im using the example Client_cpp_sdk latest version available. im trying to get the endpoints of an Server that is registered at the OPC UA Foundation LDS-ME on a another host.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3069
Joined: 18 Mar 2011, 15:09

Re: FindServerOnNetwork

Post by Support Team »

Hello samsa123,

here's a sample how to call findServersOnNetwork.

Code: Select all

    UaDiscovery discovery;
    ServiceSettings serviceSettings;
    UaString sDiscoveryUrl = "opc.tcp://localhost:4840";
    SessionSecurityInfo sessionSecurityInfo;
    OpcUa_UInt32 startingRecordId = 0;
    UaDateTime lastCounterResetTime;
    UaServerOnNetworks servers;

    UaStatus status = discovery.findServersOnNetwork(
        serviceSettings,        // Use default settings
        sDiscoveryUrl,          // Discovery Server Url
        sessionSecurityInfo,    // Use general settings for client
        startingRecordId,       // 0 since we want to get all records
        lastCounterResetTime,
        servers);

    if (status.isGood())
    {
        for (OpcUa_UInt32 i = 0; i < servers.length(); i++)
        {
            UaServerOnNetwork server(servers[i]);
            printf("********************************************************\n");
            printf("servers[%d].ServerName: %s\n", i, server.getServerName().toUtf8());
            printf("servers[%d].DiscoveryUrl: %s\n", i, server.getDiscoveryUrl().toUtf8());
        }
    }
    else
    {
        // Handle Error
    }
Best regards
Unified Automation Support Team

samsa123
Jr. Member
Jr. Member
Posts: 2
Joined: 02 Nov 2017, 11:39

Re: FindServerOnNetwork

Post by samsa123 »

it works! i can now discover all the servers on the local network.
thanks for the quick reply.

Post Reply