deno.conn

🌙
手机阅读
本文目录结构

继承关系

索引

Properties

Methods

Properties

localAddr

localAddr: Addr

连接的本地地址。

The local address of the connection.

remoteAddr

remoteAddr: Addr

连接的远程地址。

The remote address of the connection.

rid

rid: number

连接的资源 ID。

The resource ID of the connection.

Methods

close

closeRead

  • closeRead(): void

  • 关闭 (shutdown(2)) TCP 连接的读取端。大多数调用者应该只使用 close()

    Shuts down (shutdown(2)) the reading side of the TCP connection. Most callers should just use close().

    返回 void

closeWrite

  • closeWrite(): void

  • 关闭 (shutdown(2)) TCP 连接的写入端。大多数调用者应该只使用 close()

    Shuts down (shutdown(2)) the writing side of the TCP connection. Most callers should just use close().

    返回 void

read

  • read(p: Uint8Array): Promise<number | unique symbol>

  • 继承自 Reader.read

    最多读取 p.byteLength 个字节到p中,然后返回读取的字节数(0 < n <= p.byteLength),并在遇到任何错误时返回拒绝状态的回调函数。 即使 read() 返回值为 n < p.byteLength,p也可能在调用期间被用作临时空间。 如果有数据可用,但不存在 p.byteLengthread() 通常会返回可用值,而不是等待更多。

    Reads up to p.byteLength bytes into p. It resolves to the number of bytes read (0 < n <= p.byteLength) and rejects if any error encountered. Even if read() resolves to n < p.byteLength, it may use all of p as scratch space during the call. If some data is available but not p.byteLength bytes, read() conventionally resolves to what is available instead of waiting for more.

    read() 遇到文件结束条件时,将返回 Deno.EOF 符号。

    When read() encounters end-of-file condition, it resolves to Deno.EOF symbol.

    read() 遇到错误时,它会返回拒绝状态的回调函数,参数值为错误信息。

    When read() encounters an error, it rejects with an error.

    调用者应始终处理返回值为 n > 0 的情况,然后再考虑 EOF。 应正确处理在读取一些字节以及两种被允许的EOF行为之后可能发生的 I/O 错误。

    Callers should always process the n > 0 bytes returned before considering the EOF. Doing so correctly handles I/O errors that happen after reading some bytes and also both of the allowed EOF behaviors.

    实现不应保留对 p 的引用。

    Implementations should not retain a reference to p.

    参数

    • p: Uint8Array

    返回 Promise<number | unique symbol>

write

  • write(p: Uint8Array): Promise<number>

  • 继承自 Writer.write

    p 中的 p.byteLength 字节写入底层数据流。 它 resolve 时返回值为从 p 写入的 字节数(0 <= n <= p.byteLength),reject 时返回值为导致写入提前停止的错误。 如果将要 resolve 一个 n < p.byteLength 的值时, write() 必须 reject,并且返回 一个非空错误。write() 禁止修改分片数据,即使是临时修改。

    Writes p.byteLength bytes from p to the underlying data stream. It resolves to the number of bytes written from p (0 <= n <= p.byteLength) or reject with the error encountered that caused the write to stop early. write() must reject with a non-null error if would resolve to n < p.byteLength. write() must not modify the slice data, even temporarily.

    实现不应保留对 p 的引用。

    Implementations should not retain a reference to p.

    参数

    • p: Uint8Array

    返回 Promise<number>

图例说明

  • Property
  • Method

本文档使用 TypeDoc 生成。

AXIHE / 精选资源

浏览全部教程

面试题

学习网站

前端培训
自己甄别

前端书籍

关于朱安邦

我叫 朱安邦,阿西河的站长,在杭州。

以前是一名平面设计师,后来开始接接触前端开发,主要研究前端技术中的JS方向。

业余时间我喜欢分享和交流自己的技术,欢迎大家关注我的 Bilibili

关注我: Github / 知乎

于2021年离开前端领域,目前重心放在研究区块链上面了

我叫朱安邦,阿西河的站长

目前在杭州从事区块链周边的开发工作,机械专业,以前从事平面设计工作。

2014年底脱产在老家自学6个月的前端技术,自学期间几乎从未出过家门,最终找到了满意的前端工作。更多>

于2021年离开前端领域,目前从事区块链方面工作了