Obsolete
/
libipc-old
Archived
3
0
Fork 0
This repository has been archived on 2024-06-18. You can view files and clone it, but cannot push or open issues/pull-requests.
libipc-old/zig-impl/other/write-tcpd-pong-messages.zig

32 lines
909 B
Zig
Raw Normal View History

2023-01-20 04:04:12 +01:00
const std = @import("std");
const ipc = @import("./ipc.zig");
const hexdump = @import("./hexdump.zig");
const print = std.debug.print;
pub fn main() !void {
var allocator = std.heap.c_allocator;
var buffer = [_]u8{0} ** 10000;
var fbs = std.io.fixedBufferStream(&buffer);
var writer = fbs.writer();
var m = try ipc.Message.init (9, allocator, "hello this is me!");
defer m.deinit();
_ = try m.write(writer);
var msg_bytes = fbs.getWritten();
// var hexbuf: [4000]u8 = undefined;
// var hexfbs = std.io.fixedBufferStream(&hexbuf);
// var hexwriter = hexfbs.writer();
// try hexdump.hexdump(hexwriter, "What should be written in output", msg_bytes);
// print("{s}\n", .{hexfbs.getWritten()});
var out = std.io.getStdOut();
_ = try out.write("pong");
std.time.sleep(1_000_000_000); // wait for 1 seconds
_ = try out.write(msg_bytes);
}