Sample code for 30+ languages & platforms
Zig

Restart Transfer-Rate Measurement

See more Socket/SSL/TLS Examples

Demonstrates Socket.ResetPerf, which restarts one direction of connection-level transfer-rate measurement.

Background. Pass true to reset the receive measurement (RcvBytesPerSec) or false to reset the send measurement (SendBytesPerSec).

Chilkat Zig Downloads

Zig
const std = @import("std");
const chilkat = @import("chilkat");

pub fn main(init: std.process.Init) !void {
    const alloc = init.arena.allocator();

    const socket = try chilkat.Socket.init();
    defer socket.deinit();

    // Connect to the server using TLS.
    const b_tls = true;
    const max_wait_ms = 5000;
    socket.connect("example.com", 5000, b_tls, max_wait_ms) catch {
        std.debug.print("{s}\n", .{try socket.getLastErrorText(alloc)});
        return;
    };

    // Restart one direction of transfer-rate measurement.  Pass true to reset the receive measurement
    // (RcvBytesPerSec) or false to reset the send measurement (SendBytesPerSec).
    const b_rcv_perf = true;
    socket.resetPerf(b_rcv_perf);
    std.debug.print("Receive-rate measurement restarted.\n", .{});
}