Skip to content
FutureBlitz

    Install

    Import std.net.lan

    LanAnnouncer

    std.net.lan

    class

    Public Class LanAnnouncer

    Offers a service to the LAN: it answers what Lan.Find and DNS-SD's other browsers ask, on the main thread, as Async code does, from Start until Stop, or until it goes, keeping the program running meanwhile, as a listener's AcceptAsync does. It doesn't check that no other service of its type has its name, as a DNS-SD responder's probe would, so names should differ, by the machine's name, say.

    std/net/lan.fb, line 114

    • @PanicsAtCaller Public Static Method Start(type: String, name: String, port: UInt16, text: Map<String, String>? = Null, discoveryPort: UInt16 = MDNS_PORT): LanAnnouncer Throws NetError static method #

      Starts offering the service name of type, which is "_" and up to 15 lowercase letters, digits, and '-', then "._udp" or "._tcp", at port of this machine, with text as its keys and values, each pair 255 bytes at most and 8192 in all, each key once whatever its letters' case. A type, name, or text that isn't one panics. It answers at mDNS's port, 5353, or at discoveryPort, which Find has to be given too. What it sends through an interface gives that interface's address alone, as RFC 6762 has it.

    • Public Property Service: LanService property #

      Its service, as Find gives it, with this machine's addresses.

    • Public Property IsStopped: Bool property #

      Whether Stop stopped it.

    • Public Method Stop() method #

      Says goodbye to the LAN, so other mDNS caches drop the service's records, but not its host's addresses, which other services can have, and stops answering.

    Report an issue with this page or with FutureBlitz on GitHub.