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

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

A modern runtime for JavaScript and TypeScript.
Go to Latest
interface Deno.DatagramConn
implements AsyncIterable<[Uint8Array, Addr]>
import { type Deno } from "https://deno.land/x/deno@v1.28.3/cli/tsc/dts/lib.deno.unstable.d.ts";
const { DatagramConn } = Deno;

UNSTABLE: New API, yet to be vetted.

A generic transport listener for message-oriented protocols.

Properties

readonly
addr: Addr

Return the address of the instance.

Methods

receive(p?: Uint8Array): Promise<[Uint8Array, Addr]>

Waits for and resolves to the next message to the instance.

Messages are received in the format of a tuple containing the data array and the address information.

send(p: Uint8Array, addr: Addr): Promise<number>

Sends a message to the target via the connection. The method resolves with the number of bytes sent.

close(): void

Close closes the socket. Any pending message promises will be rejected with errors.

[[Symbol.asyncIterator]](): AsyncIterableIterator<[Uint8Array, Addr]>