Skip to main content
Module

x/deno/js/net.ts>listen

A modern runtime for JavaScript and TypeScript.
Go to Latest
function listen
import { listen } from "https://deno.land/x/deno@v0.17.0/js/net.ts";

Listen announces on the local network address.

The network must be tcp, tcp4, tcp6, unix or unixpacket.

For TCP networks, if the host in the address parameter is empty or a literal unspecified IP address, listen() listens on all available unicast and anycast IP addresses of the local system. To only use IPv4, use network tcp4. The address can use a host name, but this is not recommended, because it will create a listener for at most one of the host's IP addresses. If the port in the address parameter is empty or 0, as in 127.0.0.1: or [::1]:0, a port number is automatically chosen. The addr() method of Listener can be used to discover the chosen port.

See dial() for a description of the network and address parameters.

Parameters

network: Network
address: string