Usage in Deno
import * as mod from "node:net";
Stability: 2 - Stable
The node:net
module provides an asynchronous network API for creating stream-based
TCP or IPC
servers (createServer) and clients
(createConnection).
It can be accessed using:
import net from 'node:net';
This class is used to create a TCP or IPC
server.
This class is an abstraction of a TCP socket or a streaming IPC
endpoint(uses named pipes on Windows, and Unix domain sockets otherwise). It is alsoan EventEmitter
.
- addListener
- address
- autoSelectFamilyAttemptedAddresses
- bufferSize
- bytesRead
- bytesWritten
- connect
- connecting
- destroySoon
- destroyed
- emit
- end
- localAddress
- localFamily
- localPort
- on
- once
- pause
- pending
- prependListener
- prependOnceListener
- readyState
- ref
- remoteAddress
- remoteFamily
- remotePort
- resetAndDestroy
- resume
- setEncoding
- setKeepAlive
- setNoDelay
- setTimeout
- timeout
- unref
- write
Aliases to createConnection.
A factory function, which creates a new Socket,immediately initiates connection with socket.connect()
,then returns the net.Socket
that starts the connection.
Creates a new TCP or IPC
server.
Gets the current default value of the autoSelectFamily
option of socket.connect(options)
.The initial default value is true
, unless the command line option--no-network-family-autoselection
is provided.
Gets the current default value of the autoSelectFamilyAttemptTimeout
option of socket.connect(options)
.The initial default value is 250
or the value specified via the command line option --network-family-autoselection-attempt-timeout
.
Returns 6
if input
is an IPv6 address. Returns 4
if input
is an IPv4address in dot-decimal notation with no leading zeroes. Otherwise, returns0
.
Returns true
if input
is an IPv4 address in dot-decimal notation with noleading zeroes. Otherwise, returns false
.
Returns true
if input
is an IPv6 address. Otherwise, returns false
.
Sets the default value of the autoSelectFamily
option of socket.connect(options)
.
Sets the default value of the autoSelectFamilyAttemptTimeout
option of socket.connect(options)
.