### Monitor Network Interface Changes Source: https://github.com/wadetregaskis/networkinterfaceinfo/blob/main/README.md This example shows how to monitor for additions, modifications, and removals of network interfaces. This functionality is available on Apple platforms and requires importing both NetworkInterfaceInfo and NetworkInterfaceChangeMonitoring. Be aware that Network.NWPathMonitor may have delays in detecting changes. ```swift import NetworkInterfaceInfo import NetworkInterfaceChangeMonitoring for try await change in NetworkInterface.changes() { switch change.nature { case .added: print("New network interface: \(change.interface)") case .modified(let modificationNature): if modificationNature.contains(.address) { print("Address changed to \(change.interface.address).") } case .removed: // etc } } ``` -------------------------------- ### Filter Active IPv4 Network Interfaces Source: https://github.com/wadetregaskis/networkinterfaceinfo/blob/main/README.md This snippet demonstrates how to retrieve all active IPv4 network interfaces, excluding loopback interfaces. Ensure you have imported the NetworkInterfaceInfo library. ```swift import NetworkInterfaceInfo try NetworkInterface.all .filter { $0.up // Only active network interfaces… && !$0.loopback } // Ignoring loopback interfaces… .compactMap(\.address) // That have addresses and… .filter(\.isIPv4) // Use IPv4. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.