hammerspoon2-docs
    Preparing search index...

    Class HSNetworkReachability

    An active or inactive network reachability monitor. Create with hs.network.reachability*().

    Index

    Constructors

    Properties

    typeName: string

    Always "HSNetworkReachability".

    Methods

    • Replaces the callback invoked when reachability changes. The callback receives (reachability, flags) where flags is the same numeric bitmask as returned by status(). Call start() after setCallback() to begin monitoring.

      Parameters

      • callback: (reachability: HSNetworkReachability, flags: number) => void

        Called on each reachability status change.

      Returns HSNetworkReachability

      This reachability object for chaining.

    • Starts monitoring for reachability changes. After calling start(), the callback registered with setCallback() is invoked whenever the reachability status changes.

      Returns HSNetworkReachability

      This reachability object for chaining.

    • Returns the current reachability flags as a numeric bitmask. Compare against constants in hs.network.reachabilityFlags. Returns 0 if the network is currently unreachable.

      Returns number

      A number representing the current reachability bitmask.

    • Returns a human-readable summary of the current reachability flags. The string contains 8 characters in order: t (transient/expensive), R (reachable), c (connectionRequired), C (connectionOnTraffic — always -), i (interventionRequired/constrained), D (connectionOnDemand — always -), l (isLocalAddress — always -), d (isDirect). A letter appears when that flag is set; - appears when it is clear.

      Returns string

      An 8-character flag string such as "-R-----d".

    • Stops monitoring for reachability changes. The callback will no longer be invoked. Call start() again to resume monitoring.

      Returns HSNetworkReachability

      This reachability object for chaining.