All Projects → samiyr → SwiftyPing

samiyr / SwiftyPing

Licence: MIT license
ICMP ping client for Swift 5

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to SwiftyPing

StoreHelper
Implementing and testing In-App Purchases with StoreKit2 and StoreHelper in Xcode 13, Swift 5.5, SwiftUI, iOS 15 and macOS 12.
Stars: ✭ 158 (+22.48%)
Mutual labels:  swift5
SwiftRadix
Easily convert integers to binary/hex/octal strings and back again with clean functional syntax.
Stars: ✭ 34 (-73.64%)
Mutual labels:  swift5
TinyRage
Flappy Bird for WatchOS 6+ written in swift 5 using spriteKit
Stars: ✭ 23 (-82.17%)
Mutual labels:  swift5
RichEditorView
Rich Text Editor in Swift. Newly Featured Code and Swift 5 compatible of cjwirth/RichEditorView.
Stars: ✭ 105 (-18.6%)
Mutual labels:  swift5
MMActionSheet
An actionSheet view implement with pure swift
Stars: ✭ 25 (-80.62%)
Mutual labels:  swift5
SwiftUI-App
This swiftUI Demo is very simple & easy to understand. This swiftUI demo includes On-boarding screens, login screen, forgot password screen, sign up screen, home & logout.
Stars: ✭ 175 (+35.66%)
Mutual labels:  swift5
VideoTimelineView
Video timeline UI for iOS Apps
Stars: ✭ 103 (-20.16%)
Mutual labels:  swift5
JSONPreview
🎨 A view that previews JSON in highlighted form, it also provides the ability to format and collapse nodes.
Stars: ✭ 21 (-83.72%)
Mutual labels:  swift5
SwiftTTPageController
最常见的标签控制器,仿今日头条首页、网易新闻首页 ,实现多个ViewController列表切换(更新适配Swift5)
Stars: ✭ 26 (-79.84%)
Mutual labels:  swift5
EnumKit
EnumKit is a library that gives you the ability to simply access an enum associated value, without having to use pattern matching. It also offers many utilities available to other swift types, like updatability of an associated value and transformations.
Stars: ✭ 91 (-29.46%)
Mutual labels:  swift5
FireSnapshot
A useful Firebase-Cloud-Firestore Wrapper with Codable.
Stars: ✭ 56 (-56.59%)
Mutual labels:  swift5
iOS-SwiftUI-Firebase-Login-Example
Complete Sign up and Sign in Process for iOS SwiftUI - using Firebase Email and Password Authentication.
Stars: ✭ 37 (-71.32%)
Mutual labels:  swift5
DPVideoMerger-Swift
Multiple videos merge in one video with manage scale & aspect ratio and also merge videos to grid matrix layout for Swift.
Stars: ✭ 49 (-62.02%)
Mutual labels:  swift5
XYColor
An easy way to adapter dark mode on CALayer. iOS 快速适配夜间模式
Stars: ✭ 76 (-41.09%)
Mutual labels:  swift5
Combinative
UI event handling using Apple's combine framework.
Stars: ✭ 106 (-17.83%)
Mutual labels:  swift5
awesome-ios
A collaborative list of awesome for iOS developers. Include quick preview.
Stars: ✭ 1,329 (+930.23%)
Mutual labels:  swift5
core-data-model-description
Declarative way to describe a Core Data model in code.
Stars: ✭ 60 (-53.49%)
Mutual labels:  swift5
m3u8ToMP4
iOS demo,avplayer play m3u8 .ts file
Stars: ✭ 22 (-82.95%)
Mutual labels:  swift5
SwiftQRCodeScanner
An easy QR code reader for iOS written in Swift
Stars: ✭ 49 (-62.02%)
Mutual labels:  swift5
gen icmp
ICMP protocol implementation for Erlang without NIFs
Stars: ✭ 26 (-79.84%)
Mutual labels:  icmp-ping

SwiftyPing

ICMP ping client for Swift 5

SwiftyPing is an easy-to-use, one file ICMP ping client

This project is based on SwiftPing: https://github.com/ankitthakur/SwiftPing.

Usage

// Ping indefinitely
let pinger = try? SwiftyPing(host: "1.1.1.1", configuration: PingConfiguration(interval: 0.5, with: 5), queue: DispatchQueue.global())
pinger?.observer = { (response) in
    let duration = response.duration
    print(duration)
}
try? pinger?.startPinging()

// Ping once
let once = try? SwiftyPing(host: "1.1.1.1", configuration: PingConfiguration(interval: 0.5, with: 5), queue: DispatchQueue.global())
once?.observer = { (response) in
    let duration = response.duration
    print(duration)
}
once?.targetCount = 1
try? once?.startPinging()

Installation

Just drop the SwiftyPing.swift file to your project. Using SwiftyPing for a Mac application requires allowing Network->Incoming Connections and Network->Outgoing Connections in the application sandbox.

You can also use Swift Package Manager:

.Package(url: "https://github.com/samiyr/SwiftyPing.git", branch: "master")

Future development and contributions

I made this project based on what I need, so I probably won't be adding any features unless I really need them. I will maintain it (meaning bug fixes and support for new Swift versions) for some time at least. However, you can submit a pull request and I'll take a look. Please try to keep the overall coding style.

Caveats

This is low-level code, basically C code translated to Swift. This means that there are unsafe casts from raw bytes to Swift structs, for which Swift's usual type safety checks no longer apply. These can fail ungracefully (throwing an exception), and may even be used as an exploit (I'm not a security researcher and thus don't have the expertise to say for sure), so use with caution, especially if pinging untrusted hosts.

Also, while I think that the API is now stable, I don't make any guarantees – some new version might break old stuff.

License

Use pretty much however you want. Officially licensed under MIT.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].