You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|**`host`**|`<string>`|**Required**. A valid server IP address in IPv4 format or `"localhost"`. |
165
-
|**`port`**|`<number>`|**Required**. A valid server port. |
166
-
|`[localAddress]`|`<string>`| A valid local IP address to bind the socket. If not specified, the OS will decide. It is **highly recommended** to specify a `localAddress` to prevent overload errors and improve performance. |
167
-
|`[localPort]`|`<number>`| A valid local port to bind the socket. If not specified, the OS will decide. |
168
-
|`[interface]`|`<string>`| The interface to bind the socket. If not specified, it will use the current active connection. The options are: `"wifi"`. |
158
+
`createConnection(options[, callback])` creates a TCP connection using the given [`options`](#createconnection-options).
159
+
##### `createConnection: options`
160
+
**Required**. Available options for creating a socket. It must be an `object` with the following properties:
|**`port`**|`<number>`| ✅ | ✅ |**Required**. Port the socket should connect to. |
165
+
|`host`|`<string>`| ✅ | ✅ | Host the socket should connect to. IP address in IPv4 format or `'localhost'`. **Default**: `'localhost'`. |
166
+
|`localAddress`|`<string>`| ✅ | ✅ | Local address the socket should connect from. If not specified, the OS will decide. It is **highly recommended** to specify a `localAddress` to prevent overload errors and improve performance. |
167
+
|`localPort`|`<number>`| ✅ | ✅ | Local port the socket should connect from. If not specified, the OS will decide. |
168
+
|`interface`|`<string>`| ❌ | ✅ | Interface the socket should connect from. If not specified, it will use the current active connection. The options are: `'wifi'`. |
**Note**: The platforms marked as ❌ use the default value.
169
172
170
173
#### `write()`
171
174
*`data`: `<string> | <Buffer> | <Uint8Array>`
@@ -177,11 +180,22 @@ server.on('close', () => {
177
180
### Server
178
181
***Methods:**
179
182
*[`createServer(callback)`](#createserver)
180
-
*[`listen(port[, host])`](#listen)
183
+
*[`listen(options[, callback])`](#listen)
181
184
*[`close()`](#close)
182
185
183
186
#### `listen()`
184
-
`listen(port[, host])` creates a TCP server socket listening on the given port. If the host is not explicity selected, the socket will be bound to `'0.0.0.0'`.
187
+
`listen(options[, callback])` creates a TCP server socket using the given [`options`](#listen-options).
188
+
189
+
##### `listen: options`
190
+
**Required**. Available options for creating a server socket. It must be an `object` with the following properties:
0 commit comments