Zig Requires Chilkat v11.0.0+
Zig
Example: Socket.AcceptNext method
Demonstrates how to call the AcceptNext method.Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
const listen_socket = try chilkat.Socket.init();
defer listen_socket.deinit();
const connected_socket = try chilkat.Socket.init();
defer connected_socket.deinit();
const port = 5555;
const backlog = 25;
listen_socket.bindAndListen(port, backlog) catch {
std.debug.print("{s}\n", .{try listen_socket.getLastErrorText(alloc)});
return;
};
// Accept next incoming connection
var max_wait_ms: i32 = 200000;
listen_socket.acceptNext(max_wait_ms, connected_socket) catch {
std.debug.print("{s}\n", .{try listen_socket.getLastErrorText(alloc)});
return;
};
// ...
// ...
max_wait_ms = 20000;
connected_socket.close(max_wait_ms) catch {};
}