Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/deno/cli/tsc/dts/lib.deno.unstable.d.ts>Deno.connect

A modern runtime for JavaScript and TypeScript.
Go to Latest
function Deno.connect
allow-net
allow-read
import { Deno } from "https://deno.land/x/deno@v1.32.3/cli/tsc/dts/lib.deno.unstable.d.ts";
const { connect } = Deno;

UNSTABLE: New API, yet to be vetted.

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).

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" });
const conn5 = await Deno.connect({ path: "/foo/bar.sock", transport: "unix" });

Requires allow-net permission for "tcp" and allow-read for "unix".

Parameters

options: ConnectOptions

Returns

Promise<TcpConn>

UNSTABLE: New API, yet to be vetted.

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).

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" });
const conn5 = await Deno.connect({ path: "/foo/bar.sock", transport: "unix" });

Requires allow-net permission for "tcp" and allow-read for "unix".

Returns

Promise<UnixConn>