Skip to main content
Socket.prototype.on - node__net.d.ts - Node documentation
method Socket.prototype.on

Usage in Deno

```typescript import { Socket } from "node:node__net.d.ts"; ```
Socket.prototype.on(
event: string,
listener: (...args: any[]) => void,
): this

Parameters

event: string
listener: (...args: any[]) => void

Return Type

this
Socket.prototype.on(
event: "close",
listener: (hadError: boolean) => void,
): this

Parameters

event: "close"
listener: (hadError: boolean) => void

Return Type

this
Socket.prototype.on(
event: "connect",
listener: () => void,
): this

Parameters

event: "connect"
listener: () => void

Return Type

this
Socket.prototype.on(
event: "connectionAttempt",
listener: (
ip: string,
port: number,
family: number,
) => void
,
): this

Parameters

event: "connectionAttempt"
listener: (
ip: string,
port: number,
family: number,
) => void

Return Type

this
Socket.prototype.on(
event: "connectionAttemptFailed",
listener: (
ip: string,
port: number,
family: number,
) => void
,
): this

Parameters

event: "connectionAttemptFailed"
listener: (
ip: string,
port: number,
family: number,
) => void

Return Type

this
Socket.prototype.on(
event: "connectionAttemptTimeout",
listener: (
ip: string,
port: number,
family: number,
) => void
,
): this

Parameters

event: "connectionAttemptTimeout"
listener: (
ip: string,
port: number,
family: number,
) => void

Return Type

this
Socket.prototype.on(
event: "data",
listener: (data: Buffer) => void,
): this

Parameters

event: "data"
listener: (data: Buffer) => void

Return Type

this
Socket.prototype.on(
event: "drain",
listener: () => void,
): this

Parameters

event: "drain"
listener: () => void

Return Type

this
Socket.prototype.on(
event: "end",
listener: () => void,
): this

Parameters

event: "end"
listener: () => void

Return Type

this
Socket.prototype.on(
event: "error",
listener: (err: Error) => void,
): this

Parameters

event: "error"
listener: (err: Error) => void

Return Type

this
Socket.prototype.on(
event: "lookup",
listener: (
err: Error,
address: string,
family: string | number,
host: string,
) => void
,
): this

Parameters

event: "lookup"
listener: (
err: Error,
address: string,
family: string | number,
host: string,
) => void

Return Type

this
Socket.prototype.on(
event: "ready",
listener: () => void,
): this

Parameters

event: "ready"
listener: () => void

Return Type

this
Socket.prototype.on(
event: "timeout",
listener: () => void,
): this

Parameters

event: "timeout"
listener: () => void

Return Type

this