TCP, TLS, UNIX SOCKETS
Cloud & Network Services
Build TCP servers, proxies, and API gateways over TLS and Unix sockets. Async I/O is the default, so thousands of connections share a thread pool without callback pyramids.
Network code in ZZ is blocking code. Sockets, TLS, and Unix domain sockets all live in the standard library, and the runtime schedules them on green threads — a read that would block suspends the task, never the OS thread. There is no async/await colouring to thread through your types and no callback-to-future adapters to maintain.
- The full socket lifecycle — listen, accept, framed reads, and writes in `std.net`.
- TLS 1.3 and 1.2 through `std.tls`, with the same call shape as a plain socket.
- Unix domain sockets for local coordination between services on one host.
- Green threads and channels: a blocked read parks the task, not an OS thread.
- Child processes through `std.process` — spawn, wait, and read status, stdout, and stderr.
Modules
std.netstd.tlsstd.unixstd.chanstd.taskimport std.chan
import std.net
import std.task
func main() {
listener := net.tcp_listen("0.0.0.0:9000")
incoming := chan()
task.spawn(|_| {
for {
match net.accept(listener) {
.ok(stream) => chan.send(incoming, stream),
.err(e) => {
println("accept failed: {e}")
break
},
}
}
})
for {
stream := chan.recv(incoming)
task.spawn(|_| {
match net.read(stream, 4096) {
.ok(data) => net.write(stream, data),
.err(_) => net.close(stream),
}
})
}
}Runs in the playground — no install required. Open it
All four domainsBack to use casesCase studiesDocs