"Hello" is hit, but error.WouldBlock is never received (nor is the text "I found Someone" printed for that matter), However if I do connect with a client then "I found Someone" is hit. If I test the code on Linux it hits the error "error.WouldBlock".
const std = @import("std");
const net = @import("network");
const print = std.debug.print;
pub fn main() !void {
var sock = try net.Socket.create(.ipv4, .tcp);
try sock.bindToPort(5525);
try sock.listen();
// try sock.setTimeouts(1000, 1000); // This doesn't work
try sock.setReadTimeout(1000); // Neither does this
defer sock.close();
var nullable_client : ?net.Socket = null;
while (true) {
if (nullable_client) |_| {
} else {
print("Hello?\n", .{});
nullable_client = sock.accept() catch |err| switch (err) {
else => return err,
};
print("I found Someone!\n", .{});
}
}
}
I suppose that it is possible that it is intended behavior, however I find nothing referencing it in the code (from what little I have read)
"Hello" is hit, but error.WouldBlock is never received (nor is the text "I found Someone" printed for that matter), However if I do connect with a client then "I found Someone" is hit. If I test the code on Linux it hits the error "error.WouldBlock".
I suppose that it is possible that it is intended behavior, however I find nothing referencing it in the code (from what little I have read)