Skip to main content
Deno.Conn.read - Deno documentation
method Deno.Conn.read
Conn.read(p: Uint8Array): Promise<number | null>

Read the incoming data from the connection into an array buffer (p).

Resolves to either the number of bytes read during the operation or EOF (null) if there was nothing more to read.

It is possible for a read to successfully return with 0 bytes. This does not indicate EOF.

It is not guaranteed that the full buffer will be read in a single call.

// If the text "hello world" is received by the client:
const conn = await Deno.connect({ hostname: "example.com", port: 80 });
const buf = new Uint8Array(100);
const numberOfBytesRead = await conn.read(buf); // 11 bytes
const text = new TextDecoder().decode(buf);  // "hello world"

Parameters

p: Uint8Array

Return Type

Promise<number | null>
Back to top