Waits for data and reads what is there, up to buffer.count bytes. 0 is the end: the peer sent
close_notify. A connection that ends without it is an error (.CONNECTION_RESET, and
last_error says .TRUNCATED): the data may have been cut off.
- stream: the stream to read from.
- buffer: where the bytes go. Empty returns 0 at once.
read_greeting :: (stream: *Tls_Stream) -> string {
buffer: [64] u8;
count, error := read(stream, buffer);
if error != .NONE || count == 0 return "";
return copy_string(string.{ count, buffer.data });
}This one is only checked to compile, not run.
read :: (stream: *Tls_Stream, buffer: [] u8) -> (s64, Io.Io_Error)
Waits for data and reads what is there, up to buffer.count bytes. 0 is the end: the peer sent
close_notify. A connection that ends without it is an error (.CONNECTION_RESET, and
last_error says .TRUNCATED): the data may have been cut off.
Parameters
- stream: *Tls_Stream
- the stream to read from.
- buffer: [] u8
- where the bytes go. Empty returns 0 at once.
Returns
- s64
read_greeting :: (stream: *Tls_Stream) -> string {
buffer: [64] u8;
count, error := read(stream, buffer);
if error != .NONE || count == 0 return "";
return copy_string(string.{ count, buffer.data });
}This one is only checked to compile, not run.