Send ICMP Ping requests in Swift! Powered by cpp-icmplib.
Add this to the dependencies
array in Package.swift
:
.package(url: "https://github.com/LebJe/ICMPPing.git", from: "0.0.1")
Also add this to the targets
array in the aforementioned file:
.product(name: "ICMPPing", package: "ICMPPing")
Full documentation is available here.
import ICMPPing
// Google's IP Address
let address = try ICMPPing.IPAddress("8.8.8.8", type: .ipv4)
let result = ICMPPing.ping(address: address, timeout: 10 /* seconds */)
print(result)
// ICMPPing.Response(
// address: 8.8.8.8,
// code: 0,
// timeToLive: 116,
// interval: 23.011,
// responseType: ICMPPing.Response.ResponseType.success
// )
The cpp-icmplib license is available at https://github.com/markondej/cpp-icmplib/blob/c1e04b53923eec57efb898a4fdf94fea5b856c1d/LICENSE.
Before committing, please install pre-commit, swift-format, clang-format, and Prettier, then install the pre-commit hook:
$ brew bundle # install the packages specified in Brewfile
$ pre-commit install
# Commit your changes.
To install pre-commit on other platforms, refer to the documentation.