Skip to main content
Module

std/node/dgram.ts>Socket#ref

Deno standard library
Go to Latest
method Socket.prototype.ref
import { Socket } from "https://deno.land/std@0.166.0/node/dgram.ts";

By default, binding a socket will cause it to block the Node.js process from exiting as long as the socket is open. The socket.unref() method can be used to exclude the socket from the reference counting that keeps the Node.js process active. The socket.ref() method adds the socket back to the reference counting and restores the default behavior.

Calling socket.ref() multiples times will have no additional effect.

The socket.ref() method returns a reference to the socket so calls can be chained.