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

std/node/dgram.ts>Socket

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
class Socket
extends EventEmitter
import { Socket } from "https://deno.land/std@0.124.0/node/dgram.ts";

Constructors

new
Socket(_type: SocketType | SocketOption, _listener?: (msg: Buffer, rinfo: RemoteInfo) => void)

Methods

addListener(event: "close", listener: () => void): this
addListener(event: "connect", listener: () => void): this
addListener(event: "error", listener: (err: Error) => void): this
addListener(event: "listening", listener: () => void): this
addListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this
addMembership(_multicastAddress: string, _interfaceAddress?: string): void
address(): AddressInfo
addSourceSpecificMembership(
_sourceAddress: string,
_groupAddress: string,
_interfaceAddress?: string,
): void
bind(
port?: number,
address?: string,
callback?: () => void,
): this
bind(port: number, callback?: () => void): this
bind(callback: () => void): this
bind(options: BindOptions, callback?: () => void): this
close(_callback?: () => void): this
connect(
port: number,
address?: string,
callback?: () => void,
): void
connect(port: number, callback: () => void): void
disconnect(): void
dropMembership(_multicastAddress: string, _interfaceAddress?: string): void
dropSourceSpecificMembership(
_sourceAddress: string,
_groupAddress: string,
_interfaceAddress?: string,
): void
emit(event: "close"): boolean
emit(event: "connect"): boolean
emit(event: "error", err: Error): boolean
emit(event: "listening"): boolean
emit(
event: "message",
msg: Buffer,
rinfo: RemoteInfo,
): boolean
on(event: "close", listener: () => void): this
on(event: "connect", listener: () => void): this
on(event: "error", listener: (err: Error) => void): this
on(event: "listening", listener: () => void): this
on(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this
once(event: "close", listener: () => void): this
once(event: "connect", listener: () => void): this
once(event: "error", listener: (err: Error) => void): this
once(event: "listening", listener: () => void): this
once(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this
prependListener(event: "close", listener: () => void): this
prependListener(event: "connect", listener: () => void): this
prependListener(event: "error", listener: (err: Error) => void): this
prependListener(event: "listening", listener: () => void): this
prependListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this
prependOnceListener(event: "close", listener: () => void): this
prependOnceListener(event: "connect", listener: () => void): this
prependOnceListener(event: "error", listener: (err: Error) => void): this
prependOnceListener(event: "listening", listener: () => void): this
prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this
ref(): this
remoteAddress(): AddressInfo
send(
msg: MessageType | ReadonlyArray<MessageType>,
port?: number,
address?: string,
callback?: (error: Error | null, bytes: number) => void,
): void
send(
msg: MessageType | ReadonlyArray<MessageType>,
port?: number,
callback?: (error: Error | null, bytes: number) => void,
): void
send(msg: MessageType | ReadonlyArray<MessageType>, callback?: (error: Error | null, bytes: number) => void): void
send(
msg: MessageType,
offset: number,
length: number,
port?: number,
address?: string,
callback?: (error: Error | null, bytes: number) => void,
): void
send(
msg: MessageType,
offset: number,
length: number,
port?: number,
callback?: (error: Error | null, bytes: number) => void,
): void
send(
msg: MessageType,
offset: number,
length: number,
callback?: (error: Error | null, bytes: number) => void,
): void
setBroadcast(_arg: boolean): void
setMulticastInterface(_interfaceAddress: string): void
setMulticastLoopback(_arg: boolean): void
setMulticastTTL(_ttl: number): void
setRecvBufferSize(_size: number): void
setSendBufferSize(_size: number): void
setTTL(_ttl: number): void
unref(): this