Deno.connect

\color{red}{function} Deno.connect (options: ConnectOptions): Promise<Conn>

\color{red}{作用}

连接到主机

原文: Connects to the hostname (default is "127.0.0.1") and port on the named transport (default is "tcp"), and resolves to the connection (Conn).

\color{red}{参数}

port : number
hostname? : string (默认值:127.0.0.1)
transport? : "tcp"

原文:
port : number (The port to connect to.)
hostname? : string (A literal IP address or host name that can be resolved to an IP address. If not specified, defaults to 127.0.0.1.)
transport? : "tcp"

\color{red}{返回值}

Promise<Conn>

原文: Promise<Conn>

\color{red}{示列代码}

const conn1 = await Deno.connect({ port: 80 });
const conn2 = await Deno.connect({ hostname: "192.0.2.1", port: 80 });
const conn3 = await Deno.connect({ hostname: "[2001:db8::1]", port: 80 });
const conn4 = await Deno.connect({ hostname: "golang.org", port: 80, transport: "tcp" });

\color{red}{其它}

需要提供 allow-net 权限。

Requires allow-net permission for "tcp".

原文地址:点此跳转

Deno 目录

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容