Click or drag to resize

NetworkDiscoverer Class

A class used to discover printers on an IP Network.
Inheritance Hierarchy
SystemObject
  Zebra.Sdk.Printer.DiscoveryNetworkDiscoverer

Namespace:  Zebra.Sdk.Printer.Discovery
Assembly:  SdkApi_Core (in SdkApi_Core.dll) Version: 2.13.898
Syntax
public class NetworkDiscoverer

The NetworkDiscoverer type exposes the following members.

Methods
  NameDescription
Public methodStatic memberDirectedBroadcast(DiscoveryHandler, String)
Sends a directed broadcast discovery packet to the subnet specified by ipAddress.
Public methodStatic memberDirectedBroadcast(DiscoveryHandler, String, Int32)
Sends a directed broadcast discovery packet to the subnet specified by ipAddress.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodStatic memberFindPrinters(DiscoveryHandler)
This method will search the network using a combination of discovery methods to find printers on the network.
Public methodStatic memberFindPrinters(DiscoveryHandler, ListString)
Sends a discovery request to the list of printer DNS names or IPs in printersToFind.
Public methodStatic memberFindPrinters(DiscoveryHandler, ListString, Int32)
Sends a discovery request to the list of printer DNS names or IPs in printersToFind.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic memberLocalBroadcast(DiscoveryHandler)
Sends a local broadcast packet.
Public methodStatic memberLocalBroadcast(DiscoveryHandler, Int32)
Sends a local broadcast packet.
Public methodStatic memberMulticast(DiscoveryHandler, Int32)
Sends a multicast discovery packet.
Public methodStatic memberMulticast(DiscoveryHandler, Int32, Int32)
Sends a multicast discovery packet.
Public methodStatic memberSubnetSearch(DiscoveryHandler, String)
Sends a discovery packet to the IPs specified in the subnetRange.
Public methodStatic memberSubnetSearch(DiscoveryHandler, String, Int32)
Sends a discovery packet to the IPs specified in the subnetRange.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Examples
using System;
using System.Collections.Generic;
using Zebra.Sdk.Printer.Discovery;

public class NetworkDiscovererExample {

    public static void Main(string[] args) {
        try {
            Console.WriteLine("Starting printer discovery.");

            NetworkDiscoveryHandler discoveryHandler = new NetworkDiscoveryHandler();
            NetworkDiscoverer.FindPrinters(discoveryHandler);
            while (!discoveryHandler.DiscoveryComplete) {
                System.Threading.Thread.Sleep(10);
            }
        } catch (DiscoveryException e) {
            Console.WriteLine(e.ToString());
        }
    }

    private class NetworkDiscoveryHandler : DiscoveryHandler {

        private bool discoveryComplete = false;
        List<DiscoveredPrinter> printers = new List<DiscoveredPrinter>();

        public void DiscoveryError(string message) {
            Console.WriteLine($"An error occurred during discovery: {message}.");
            discoveryComplete = true;
        }

        public void DiscoveryFinished() {
            foreach (DiscoveredPrinter printer in printers) {
                Console.WriteLine(printer);
            }
            Console.WriteLine($"Discovered {printers.Count} Link-OS(TM) printers.");
            discoveryComplete = true;
        }

        public void FoundPrinter(DiscoveredPrinter printer) {
            printers.Add(printer);
        }

        public bool DiscoveryComplete {
            get => discoveryComplete;
        }
    }
}
See Also