Skip to content

Releases: samiyr/SwiftyPing

v1.2.1

09 Jun 07:13
Compare
Choose a tag to compare
  • Fix a crash when sending more than 65535 pings (thanks to @Kususumu)
  • Overall better handling of sequence indices. All the functions and result structs now use the appropriate integer types. This may be a breaking change if you depend on those values being Int types.
  • There's a new trueSequenceNumber in PingResponse and a similar private variable in SwiftyPing, which is now returned by currentCount. trueSequenceNumber is an UInt64, which will probably never overflow. This keeps track of the actual number of pings sent, even when sequenceNumber, which is just an UInt16, has overflowed and been wrapped back to 0.

v1.2

06 May 14:40
Compare
Choose a tag to compare

This release includes a new PingResult struct that's sent to a new observer finished when pinging stops. This ping result includes all the responses received, packet loss and also automatically calculates roundtrip statistics (min, max, avg, stddev). Here's an example from the SwiftyPingTest project:

let host = "1.1.1.1"
ping = try SwiftyPing(host: host, configuration: PingConfiguration(interval: 1.0, with: 1), queue: DispatchQueue.global())
ping?.observer = { (response) in
    DispatchQueue.main.async {
        var message = "\(response.duration * 1000) ms"
        if let error = response.error {
            if error == .responseTimeout {
                message = "Timeout \(message)"
            } else {
                print(error)
                message = error.localizedDescription
            }
        }
        self.textView.text.append(contentsOf: "\nPing #\(response.sequenceNumber): \(message)")
        self.textView.scrollRangeToVisible(NSRange(location: self.textView.text.count - 1, length: 1))
    }
}
ping?.finished = { (result) in
    DispatchQueue.main.async {
        var message = "\n--- \(host) ping statistics ---\n"
        message += "\(result.packetsTransmitted) transmitted, \(result.packetsReceived) received"
        if let loss = result.packetLoss {
            message += String(format: "\n%.1f%% packet loss\n", loss * 100)
        } else {
            message += "\n"
        }
        if let roundtrip = result.roundtrip {
            message += String(format: "round-trip min/avg/max/stddev = %.3f/%.3f/%.3f/%.3f ms", roundtrip.minimum * 1000, roundtrip.average * 1000, roundtrip.maximum * 1000, roundtrip.standardDeviation * 1000)
        }
        self.textView.text.append(contentsOf: message)
        self.textView.scrollRangeToVisible(NSRange(location: self.textView.text.count - 1, length: 1))
    }
}
try ping?.startPinging()

v1.1.14

05 Apr 10:11
Compare
Choose a tag to compare
  • Fixes a crash when using a serial queue with SwiftyPing (#29)
  • Fixes a memory leak (#27)

This version also includes a behavioral change related to the memory leak fix. Starting from this release, when a targetCount is set and is reached, the ping instance will be halted instead of stopped. This better reflects the nature of such ping instances: they are supposed to be one-time objects and be discarded after use. Halting the ping instance after the target count has been reached means that the socket and associated resources are released immediately, instead of when the application quits. If the same ping instance will be used later, the socket will be recreated from scratch.

This behavior is controlled by the new flag haltAfterTarget in the PingConfiguration. This flag defaults to the true, and the old behavior can be restored by setting this flag to false.

v1.1.13

18 Mar 13:11
Compare
Choose a tag to compare

Fixes access scopes (see #25)

v1.1.12

01 Mar 08:36
Compare
Choose a tag to compare

Added support for variable-sized payloads

v1.1.11

28 Feb 11:44
Compare
Choose a tag to compare
  • Test project includes Mac version
  • Fixes some erratic pinging behaviour

v1.1.10

26 Feb 08:26
Compare
Choose a tag to compare

Includes support for setting the TTL field (see issue #21)

v1.1.9

27 Jan 09:52
Compare
Choose a tag to compare

Fixes a memory leak issue (thanks @cgcym1234)

v1.1.8

06 Dec 11:33
Compare
Choose a tag to compare

Fixed an issue where the timeout timer was prematurely invalidated
Added a new currentCount property

v1.1.7

23 Oct 08:00
Compare
Choose a tag to compare

Another crash fix (#15)