TCP Networking APIs
The TCP Networking APIs provide an asynchronous network API for creating stream-based TCP servers and clients.
Classes
Members
(static, constant) connect
Aliases to net.createConnection()
.
Additional signatures:
- connect(port: number | string, host?: string)
Methods
(static) createConnection(options) → {Socket}
Initiates a connection to a given remote host.
Additional signatures:
- createConnection(port: number | string, host?: string)
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object
|
Configuration options for the connection.
|
Returns:
- Type:
-
Socket
An instance of the Socket
class
(static) createServer(onConnectionopt) → {Server}
Creates a new TCP server.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
onConnection |
function
|
<optional> |
A function that is called whenever a connection is made to the server. |
Returns:
- Type:
-
Server
An instance of the Server
class.
Type Definitions
SocketHost
Information about the host TCP socket.
Properties:
Name | Type | Description |
---|---|---|
port |
number
|
The port number on the local machine. |
family |
string
|
The IP family of the local address ( |
address |
string
|
The local IP address. |
SocketRemote
Information about the remote TCP socket.
Properties:
Name | Type | Description |
---|---|---|
port |
number
|
The port number on the remote machine. |
address |
string
|
The remote IP address. |