Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Socket

Hierarchy

Implements

  • ReadableStream
  • Writable

Index

Constructors

constructor

  • Parameters

    Returns Socket

Properties

bufferSize

bufferSize: number

bytesRead

bytesRead: number

bytesWritten

bytesWritten: number

connecting

connecting: boolean

destroyed

destroyed: boolean

localAddress

localAddress: string

localPort

localPort: number

readable

readable: boolean

readableHighWaterMark

readableHighWaterMark: number

readableLength

readableLength: number

Optional remoteAddress

remoteAddress: string

Optional remoteFamily

remoteFamily: string

Optional remotePort

remotePort: number

writable

writable: boolean

writableFinished

writableFinished: boolean

writableHighWaterMark

writableHighWaterMark: number

writableLength

writableLength: number

Static defaultMaxListeners

defaultMaxListeners: number

Methods

__@asyncIterator

  • __@asyncIterator(): AsyncIterableIterator<any>
  • Returns AsyncIterableIterator<any>

_destroy

  • _destroy(error: Error | null, callback: function): void
  • Parameters

    • error: Error | null
    • callback: function
        • (error: Error | null): void
        • Parameters

          • error: Error | null

          Returns void

    Returns void

_final

  • _final(callback: function): void
  • Parameters

    • callback: function
        • (error?: Error | null): void
        • Parameters

          • Optional error: Error | null

          Returns void

    Returns void

_read

  • _read(size: number): void
  • Parameters

    • size: number

    Returns void

_write

  • _write(chunk: any, encoding: string, callback: function): void
  • Parameters

    • chunk: any
    • encoding: string
    • callback: function
        • (error?: Error | null): void
        • Parameters

          • Optional error: Error | null

          Returns void

    Returns void

Optional _writev

  • _writev(chunks: Array<object>, callback: function): void
  • Parameters

    • chunks: Array<object>
    • callback: function
        • (error?: Error | null): void
        • Parameters

          • Optional error: Error | null

          Returns void

    Returns void

addListener

  • addListener(event: string, listener: function): this
  • addListener(event: "close", listener: function): this
  • addListener(event: "connect", listener: function): this
  • addListener(event: "data", listener: function): this
  • addListener(event: "drain", listener: function): this
  • addListener(event: "end", listener: function): this
  • addListener(event: "error", listener: function): this
  • addListener(event: "lookup", listener: function): this
  • addListener(event: "timeout", listener: function): this
  • events.EventEmitter

    1. close
    2. connect
    3. data
    4. drain
    5. end
    6. error
    7. lookup
    8. timeout

    Parameters

    • event: string
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "close"
    • listener: function
        • (had_error: boolean): void
        • Parameters

          • had_error: boolean

          Returns void

    Returns this

  • Parameters

    • event: "connect"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "data"
    • listener: function
        • (data: Buffer): void
        • Parameters

          • data: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "drain"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "end"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "error"
    • listener: function
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns this

  • Parameters

    • event: "lookup"
    • listener: function
        • (err: Error, address: string, family: string | number, host: string): void
        • Parameters

          • err: Error
          • address: string
          • family: string | number
          • host: string

          Returns void

    Returns this

  • Parameters

    • event: "timeout"
    • listener: function
        • (): void
        • Returns void

    Returns this

address

  • Returns AddressInfo | string

connect

  • connect(options: SocketConnectOpts, connectionListener?: function): this
  • connect(port: number, host: string, connectionListener?: function): this
  • connect(port: number, connectionListener?: function): this
  • connect(path: string, connectionListener?: function): this
  • Parameters

    • options: SocketConnectOpts
    • Optional connectionListener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • port: number
    • host: string
    • Optional connectionListener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • port: number
    • Optional connectionListener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • path: string
    • Optional connectionListener: function
        • (): void
        • Returns void

    Returns this

cork

  • cork(): void
  • Returns void

destroy

  • destroy(error?: Error): void
  • Parameters

    • Optional error: Error

    Returns void

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • emit(event: "close", had_error: boolean): boolean
  • emit(event: "connect"): boolean
  • emit(event: "data", data: Buffer): boolean
  • emit(event: "drain"): boolean
  • emit(event: "end"): boolean
  • emit(event: "error", err: Error): boolean
  • emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean
  • emit(event: "timeout"): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

  • Parameters

    • event: "close"
    • had_error: boolean

    Returns boolean

  • Parameters

    • event: "connect"

    Returns boolean

  • Parameters

    • event: "data"
    • data: Buffer

    Returns boolean

  • Parameters

    • event: "drain"

    Returns boolean

  • Parameters

    • event: "end"

    Returns boolean

  • Parameters

    • event: "error"
    • err: Error

    Returns boolean

  • Parameters

    • event: "lookup"
    • err: Error
    • address: string
    • family: string | number
    • host: string

    Returns boolean

  • Parameters

    • event: "timeout"

    Returns boolean

end

  • end(cb?: function): void
  • end(buffer: Uint8Array | string, cb?: function): void
  • end(str: Uint8Array | string, encoding?: string, cb?: function): void
  • Parameters

    • Optional cb: function
        • (): void
        • Returns void

    Returns void

  • Parameters

    • buffer: Uint8Array | string
    • Optional cb: function
        • (): void
        • Returns void

    Returns void

  • Parameters

    • str: Uint8Array | string
    • Optional encoding: string
    • Optional cb: function
        • (): void
        • Returns void

    Returns void

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

getMaxListeners

  • getMaxListeners(): number
  • Returns number

isPaused

  • isPaused(): boolean
  • Returns boolean

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string, listener: function): this
  • on(event: "close", listener: function): this
  • on(event: "connect", listener: function): this
  • on(event: "data", listener: function): this
  • on(event: "drain", listener: function): this
  • on(event: "end", listener: function): this
  • on(event: "error", listener: function): this
  • on(event: "lookup", listener: function): this
  • on(event: "timeout", listener: function): this
  • Parameters

    • event: string
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "close"
    • listener: function
        • (had_error: boolean): void
        • Parameters

          • had_error: boolean

          Returns void

    Returns this

  • Parameters

    • event: "connect"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "data"
    • listener: function
        • (data: Buffer): void
        • Parameters

          • data: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "drain"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "end"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "error"
    • listener: function
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns this

  • Parameters

    • event: "lookup"
    • listener: function
        • (err: Error, address: string, family: string | number, host: string): void
        • Parameters

          • err: Error
          • address: string
          • family: string | number
          • host: string

          Returns void

    Returns this

  • Parameters

    • event: "timeout"
    • listener: function
        • (): void
        • Returns void

    Returns this

once

  • once(event: string, listener: function): this
  • once(event: "close", listener: function): this
  • once(event: "connect", listener: function): this
  • once(event: "data", listener: function): this
  • once(event: "drain", listener: function): this
  • once(event: "end", listener: function): this
  • once(event: "error", listener: function): this
  • once(event: "lookup", listener: function): this
  • once(event: "timeout", listener: function): this
  • Parameters

    • event: string
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "close"
    • listener: function
        • (had_error: boolean): void
        • Parameters

          • had_error: boolean

          Returns void

    Returns this

  • Parameters

    • event: "connect"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "data"
    • listener: function
        • (data: Buffer): void
        • Parameters

          • data: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "drain"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "end"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "error"
    • listener: function
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns this

  • Parameters

    • event: "lookup"
    • listener: function
        • (err: Error, address: string, family: string | number, host: string): void
        • Parameters

          • err: Error
          • address: string
          • family: string | number
          • host: string

          Returns void

    Returns this

  • Parameters

    • event: "timeout"
    • listener: function
        • (): void
        • Returns void

    Returns this

pause

  • pause(): this
  • Returns this

pipe

  • pipe<T>(destination: T, options?: object): T
  • Type parameters

    • T: WritableStream

    Parameters

    • destination: T
    • Optional options: object
      • Optional end?: boolean

    Returns T

prependListener

  • prependListener(event: string, listener: function): this
  • prependListener(event: "close", listener: function): this
  • prependListener(event: "connect", listener: function): this
  • prependListener(event: "data", listener: function): this
  • prependListener(event: "drain", listener: function): this
  • prependListener(event: "end", listener: function): this
  • prependListener(event: "error", listener: function): this
  • prependListener(event: "lookup", listener: function): this
  • prependListener(event: "timeout", listener: function): this
  • Parameters

    • event: string
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "close"
    • listener: function
        • (had_error: boolean): void
        • Parameters

          • had_error: boolean

          Returns void

    Returns this

  • Parameters

    • event: "connect"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "data"
    • listener: function
        • (data: Buffer): void
        • Parameters

          • data: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "drain"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "end"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "error"
    • listener: function
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns this

  • Parameters

    • event: "lookup"
    • listener: function
        • (err: Error, address: string, family: string | number, host: string): void
        • Parameters

          • err: Error
          • address: string
          • family: string | number
          • host: string

          Returns void

    Returns this

  • Parameters

    • event: "timeout"
    • listener: function
        • (): void
        • Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string, listener: function): this
  • prependOnceListener(event: "close", listener: function): this
  • prependOnceListener(event: "connect", listener: function): this
  • prependOnceListener(event: "data", listener: function): this
  • prependOnceListener(event: "drain", listener: function): this
  • prependOnceListener(event: "end", listener: function): this
  • prependOnceListener(event: "error", listener: function): this
  • prependOnceListener(event: "lookup", listener: function): this
  • prependOnceListener(event: "timeout", listener: function): this
  • Parameters

    • event: string
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "close"
    • listener: function
        • (had_error: boolean): void
        • Parameters

          • had_error: boolean

          Returns void

    Returns this

  • Parameters

    • event: "connect"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "data"
    • listener: function
        • (data: Buffer): void
        • Parameters

          • data: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "drain"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "end"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "error"
    • listener: function
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns this

  • Parameters

    • event: "lookup"
    • listener: function
        • (err: Error, address: string, family: string | number, host: string): void
        • Parameters

          • err: Error
          • address: string
          • family: string | number
          • host: string

          Returns void

    Returns this

  • Parameters

    • event: "timeout"
    • listener: function
        • (): void
        • Returns void

    Returns this

push

  • push(chunk: any, encoding?: string): boolean
  • Parameters

    • chunk: any
    • Optional encoding: string

    Returns boolean

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

read

  • read(size?: number): any
  • Parameters

    • Optional size: number

    Returns any

ref

  • ref(): void
  • Returns void

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: "close", listener: function): this
  • removeListener(event: "data", listener: function): this
  • removeListener(event: "end", listener: function): this
  • removeListener(event: "readable", listener: function): this
  • removeListener(event: "error", listener: function): this
  • removeListener(event: string | symbol, listener: function): this
  • Parameters

    • event: "close"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "data"
    • listener: function
        • (chunk: any): void
        • Parameters

          • chunk: any

          Returns void

    Returns this

  • Parameters

    • event: "end"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "readable"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "error"
    • listener: function
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns this

  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

resume

  • resume(): this
  • Returns this

setDefaultEncoding

  • setDefaultEncoding(encoding: string): this
  • Parameters

    • encoding: string

    Returns this

setEncoding

  • setEncoding(encoding?: string): this
  • Parameters

    • Optional encoding: string

    Returns this

setKeepAlive

  • setKeepAlive(enable?: boolean, initialDelay?: number): this
  • Parameters

    • Optional enable: boolean
    • Optional initialDelay: number

    Returns this

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

setNoDelay

  • setNoDelay(noDelay?: boolean): this
  • Parameters

    • Optional noDelay: boolean

    Returns this

setTimeout

  • setTimeout(timeout: number, callback?: function): this
  • Parameters

    • timeout: number
    • Optional callback: function
        • (): void
        • Returns void

    Returns this

uncork

  • uncork(): void
  • Returns void

unpipe

  • unpipe(destination?: WritableStream): this
  • Parameters

    • Optional destination: WritableStream

    Returns this

unref

  • unref(): void
  • Returns void

unshift

  • unshift(chunk: any, encoding?: BufferEncoding): void
  • Parameters

    • chunk: any
    • Optional encoding: BufferEncoding

    Returns void

wrap

  • wrap(oldStream: ReadableStream): this
  • Parameters

    • oldStream: ReadableStream

    Returns this

write

  • write(buffer: Uint8Array | string, cb?: function): boolean
  • write(str: Uint8Array | string, encoding?: string, cb?: function): boolean
  • Parameters

    • buffer: Uint8Array | string
    • Optional cb: function
        • (err?: Error): void
        • Parameters

          • Optional err: Error

          Returns void

    Returns boolean

  • Parameters

    • str: Uint8Array | string
    • Optional encoding: string
    • Optional cb: function
        • (err?: Error): void
        • Parameters

          • Optional err: Error

          Returns void

    Returns boolean

Static from

  • from(iterable: Iterable<any> | AsyncIterable<any>, options?: ReadableOptions): Readable
  • A utility method for creating Readable Streams out of iterators.

    Parameters

    • iterable: Iterable<any> | AsyncIterable<any>
    • Optional options: ReadableOptions

    Returns Readable

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc