Deno.connect (options: ConnectOptions): Promise<Conn>
连接到主机
原文: 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).
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"
Promise<Conn>
原文: Promise<Conn>
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" });
需要提供 allow-net 权限。
Requires allow-net permission for "tcp".