-
-
Save haze/211244c6dd14f90961ad3ca71c0fbef4 to your computer and use it in GitHub Desktop.
(no description)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const net = std.net; | |
pub const io_mode = .evented; | |
pub fn main() anyerror!void { | |
const allocator = &std.heap.ArenaAllocator.init(std.heap.page_allocator).allocator; | |
const socket = try net.tcpConnectToAddress(try net.Address.parseIp("127.0.0.1", 5000)); | |
const socket_in_stream = socket.inStream(); | |
while (true) { | |
const bytes = socket_in_stream.readUntilDelimiterAlloc(allocator, '\n', 4096) catch |err| { | |
switch (err) { | |
error.EndOfStream => break, | |
else => return err, | |
} | |
}; | |
std.debug.warn("{}\n", .{bytes}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment