Esc

receive_bytes

procedureextensionsince 0.36.1Source
  • macOS: receive_bytes works on macOS
  • Linux: receive_bytes works on Linux
  • Windows: receive_bytes works on Windows
  • Wasm: receive_bytes works on Wasm

Receives one framed message into caller-owned memory. END is a byte-stream event, not application success; always inspect finish's authoritative Status. .

Signature

receive_bytes :: (call: *Call) -> (message: [] u8, kind: Receive_Kind)
Example
channel: Channel; // set transport.base_url and transport.tls before the first call
method := Method.{ path = "/echo.Echo/Say" };
call, status := open_call(*channel, method);
assert(status.code == .OK);
defer close(*call);
while true {
    message, kind := receive_bytes(*call);
    if kind != .MESSAGE break;
    defer free(message.data);
    print("% bytes\n", message.count);
}

See also