Skip to content

std.tls - ZZ

TCP networking with binary-safe transfers, real shutdown, TLS (rustls), and Unix-domain sockets. Compiled patterns are opaque handles; all fallible ops return Result<_, str>.

import std.net
import std.net
func main() -> Result<int, str> {
tls := net.tls_connect("127.0.0.1:8443", "localhost", 5000)?
tls.write("GET / HTTP/1.1\r\nHost: example.com\r\n\r\n")?
resp := tls.read(4096)?
tls.close()?
return .ok(0)
}

TLS constructors: tls_connect, tls_connect_insecure, tls_connect_with_ca. TLS listener: tls_listen, tls_accept, tls_listener_close.

17 entries. Signatures come from the compiler’s own FuncSig table, so they match the runtime exactly; descriptions come from the module guide.

Function Signature
std.tls.close close(stream: tls) -> Result<unit, str>
std.tls.connect connect(addr: str, server_name: str, timeout_ms: int) -> Result<tls, str>
std.tls.connect_insecure connect_insecure(addr: str, server_name: str, timeout_ms: int) -> Result<tls, str>
std.tls.connect_with_ca connect_with_ca(addr: str, server_name: str, ca_file: str, timeout_ms: int) -> Result<tls, str>
std.tls.peer_addr peer_addr(stream: tls) -> Result<str, str>
std.tls.read read(stream: tls, max_bytes: int) -> Result<str, str>
std.tls.read_bytes read_bytes(stream: tls, max_bytes: int) -> Result<bytes, str>
std.tls.read_exact read_exact(stream: tls, n: int) -> Result<bytes, str>
std.tls.read_line read_line(stream: tls) -> Result<str, str>
std.tls.set_read_timeout set_read_timeout(stream: tls, ms: int) -> Result<bool, str>
std.tls.set_write_timeout set_write_timeout(stream: tls, ms: int) -> Result<bool, str>
std.tls.shutdown shutdown(stream: tls) -> Result<unit, str>
std.tls.write write(stream: tls, data: str) -> Result<int, str>
std.tls.write_bytes write_bytes(stream: tls, data: bytes) -> Result<int, str>
std.tls_listener.accept accept(listener: tls_listener) -> Result<tls, str>
std.tls_listener.close close(listener: tls_listener) -> Result<bool, str>
std.tls_listener.shutdown shutdown(listener: tls_listener) -> Result<bool, str>
  • std.http — An HTTP server and client: routing, requests, responses, middleware and static files.
  • std.net — TCP sockets: connect, listen, accept and framed reads.
  • std.unix — Unix domain sockets and their listeners.

Full index: API reference · Standard library