December 23, 2025, 7:16pm 1

Hey everyone! I have been working on a simple TCP read/write example to understand how the new IO worked, and I have been having trouble setting up the reader to simply read till EOF / the end of stream.

Here’s the small example I have (echo.websocket.org is simply an echo server):

const std = @import("std");

const net = std.net;
const print = std.debug.print;

var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();

pub fn main() !void {
const host = "echo.websocket.org";
const stream = try net.tcpConnectToHost(allocator, host, 443);
defer stream.close();

print("Connecting to: {s}\n", .{host});
const data = "hello!";

var buffer: [1024]u8 = undefined;
var stream_reader = stream.reader(&buffer);
var reader = stream_r...

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help