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

x/deno/ext/net/lib.deno_net.d.ts>Deno.listen

A modern runtime for JavaScript and TypeScript.
Go to Latest
function Deno.listen
allow-net
import { Deno } from "https://deno.land/x/deno@v1.39.0/ext/net/lib.deno_net.d.ts";
const { listen } = Deno;

Listen announces on the local transport address.

const listener1 = Deno.listen({ port: 80 })
const listener2 = Deno.listen({ hostname: "192.0.2.1", port: 80 })
const listener3 = Deno.listen({ hostname: "[2001:db8::1]", port: 80 });
const listener4 = Deno.listen({ hostname: "golang.org", port: 80, transport: "tcp" });

Requires allow-net permission.

Parameters

options: TcpListenOptions & { transport?: "tcp"; }