How can I list the OPC DA (OPC Classic) Servers of a remote PC in C#

Viewed 81

I want to list the OPC DA Servers of a remote machine. Actually I use a code that can list the OPC DA (OPC classic) servers just on the local machine. How should I extend this code in order to be able to list the OPC DA servers on a remote pc? The remote PC is not in the same domain as the C# code running PC. I can ping the remote PC with its IP.

private void List_OPC_Server()
    {
        try
        {
            Opc.IDiscovery opcDiscovery = new OpcCom.ServerEnumerator();
            Opc.Server[] opcServers = opcDiscovery.GetAvailableServers(
                Opc.Specification.COM_DA_20);

            foreach (Opc.Server opcServer in opcServers)
            {
                using (StreamWriter sw = File.AppendText(OPC_Log))
                {
                    sw.WriteLine("OPC Server");
                    sw.WriteLine(opcServer.Url.Path);
                }
            }
        }
        catch (Exception except)
        {
            using (StreamWriter sw = File.AppendText(OPC_Log))
            {
                sw.WriteLine(except);
            }
        }
    }
0 Answers
Related