ResolverHostNameDriver

Driver that resolves the IPv4 of a device by its hostname. It will try to resolve using the machine DNS resolver, and if it fails it will try to resolve using mDNS.

Usage

Create an instance of the driver and subscribe to the StatusChanged event. The event will be triggered when the driver changes its status. The driver will try to resolve the hostname using the machine DNS resolver, and if it fails it will try to resolve using mDNS. The driver will return the first address that it can resolve.

var resolver = new ResolveHostnameDriver();
resolver.StatusChanged += (_, args) =>
{
    Log.Verbose("Status Changed: {@Args}", args);

};
var address = await resolver.ResolveHostname("CP4-Home");

VC-4 Notes

Under CentOs, the mDNS ports are closed by default. For your program to resolve mDNS commands the following must be done:

sudo firewall-cmd --permanent --zone=public --add-port=5353/udp
sudo firewall-cmd --reload

Serilog

The class accepts a SerilogLogger as a property. This is optional

var logger = new LoggerConfiguration()
    .WriteTo.Console()
    .CreateLogger();
var resolver.ClassLogger = logger;