Index - Node documentation

Usage

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:

const net = require('node:net');

Classes

c
BlockList

The BlockList object can be used with some network APIs to specify rules for disabling inbound or outbound access to specific IP addresses, IP ranges, or IP subnets.

c
Server

This class is used to create a TCP or IPC server.

c
Socket

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 also an EventEmitter.

c
SocketAddress
No documentation available

Functions

f
f
createConnection

A factory function, which creates a new Socket, immediately initiates connection with socket.connect(), then returns the net.Socket that starts the connection.

f
createServer

Creates a new TCP or IPC server.

f
getDefaultAutoSelectFamily

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.

f
getDefaultAutoSelectFamilyAttemptTimeout

Gets the current default value of the autoSelectFamilyAttemptTimeout option of socket.connect(options). The initial default value is 250.

f
isIP

Returns 6 if input is an IPv6 address. Returns 4 if input is an IPv4 address in dot-decimal notation with no leading zeroes. Otherwise, returns0.

f
isIPv4

Returns true if input is an IPv4 address in dot-decimal notation with no leading zeroes. Otherwise, returns false.

f
isIPv6

Returns true if input is an IPv6 address. Otherwise, returns false.

f
setDefaultAutoSelectFamily

Sets the default value of the autoSelectFamily option of socket.connect(options).

f
setDefaultAutoSelectFamilyAttemptTimeout

Sets the default value of the autoSelectFamilyAttemptTimeout option of socket.connect(options).

Interfaces

I
AddressInfo
No documentation available
I
ConnectOpts
No documentation available
I
DropArgument
No documentation available
I
IpcNetConnectOpts
No documentation available
I
IpcSocketConnectOpts
No documentation available
I
ListenOptions
No documentation available
I
OnReadOpts
No documentation available
I
ServerOpts
No documentation available
I
SocketAddressInitOptions
No documentation available
I
SocketConstructorOpts
No documentation available
I
TcpNetConnectOpts
No documentation available
I
TcpSocketConnectOpts
No documentation available

Type Aliases

T
IPVersion
No documentation available
T
LookupFunction
No documentation available
T
NetConnectOpts
No documentation available
T
SocketConnectOpts
No documentation available
T
SocketReadyState
No documentation available