@@ -17,7 +17,31 @@ const net = require('net');
17
17
The ` net ` module supports IPC with named pipes on Windows, and UNIX domain
18
18
sockets on other operating systems.
19
19
20
- * Note* : Unix named pipes (FIFOs) are not supported.
20
+ ### Identifying paths for IPC connections
21
+
22
+ [ ` net.connect() ` ] [ ] , [ ` net.createConnection() ` ] [ ] , [ ` server.listen() ` ] [ ] and
23
+ [ ` socket.connect() ` ] [ ] take a ` path ` parameter to identify IPC endpoints.
24
+
25
+ On UNIX, the local domain is also known as the UNIX domain. The path is a
26
+ filesystem path name. It gets truncated to ` sizeof(sockaddr_un.sun_path) - 1 ` ,
27
+ which varies on different operating system between 91 and 107 bytes.
28
+ The typical values are 107 on Linux and 103 on OS X. The path is
29
+ subject to the same naming conventions and permissions checks as would be done
30
+ on file creation. It will be visible in the filesystem, and will * persist until
31
+ unlinked* .
32
+
33
+ On Windows, the local domain is implemented using a named pipe. The path * must*
34
+ refer to an entry in ` \\?\pipe\ ` or ` \\.\pipe\ ` . Any characters are permitted,
35
+ but the latter may do some processing of pipe names, such as resolving ` .. `
36
+ sequences. Despite appearances, the pipe name space is flat. Pipes will * not
37
+ persist* , they are removed when the last reference to them is closed. Do not
38
+ forget JavaScript string escaping requires paths to be specified with
39
+ double-backslashes, such as:
40
+
41
+ ``` js
42
+ net .createServer ().listen (
43
+ path .join (' \\\\ ?\\ pipe' , process .cwd (), ' myctl' ))
44
+ ```
21
45
22
46
## Class: net.Server
23
47
<!-- YAML
@@ -206,13 +230,14 @@ added: v0.11.14
206
230
-->
207
231
208
232
* ` options ` {Object} Required. Supports the following properties:
209
- * ` port ` {number} Optional.
210
- * ` host ` {string} Optional.
211
- * ` path ` {string} Optional. Will be ignored if ` port ` is specified.
212
- * ` backlog ` {number} Optional. Common parameter of [ ` server.listen() ` ] [ ]
233
+ * ` port ` {number}
234
+ * ` host ` {string}
235
+ * ` path ` {string} Will be ignored if ` port ` is specified. See
236
+ [ Identifying paths for IPC connections] [ ] .
237
+ * ` backlog ` {number} Common parameter of [ ` server.listen() ` ] [ ]
213
238
functions
214
- * ` exclusive ` {boolean} Optional. Default to ` false `
215
- * ` callback ` {Function} Optional. Common parameter of [ ` server.listen() ` ] [ ]
239
+ * ` exclusive ` {boolean} Default to ` false `
240
+ * ` callback ` {Function} Common parameter of [ ` server.listen() ` ] [ ]
216
241
functions
217
242
218
243
If ` port ` is specified, it behaves the same as
@@ -240,33 +265,13 @@ server.listen({
240
265
added: v0.1.90
241
266
-->
242
267
243
- * ` path ` {string}
268
+ * ` path ` {String} Path the server should listen to. See
269
+ [ Identifying paths for IPC connections] [ ] .
244
270
* ` backlog ` {number} Common parameter of [ ` server.listen() ` ] [ ] functions
245
271
* ` callback ` {Function} Common parameter of [ ` server.listen() ` ] [ ] functions
246
272
247
273
Start a [ IPC] [ ] server listening for connections on the given ` path ` .
248
274
249
- On UNIX, the local domain is usually known as the UNIX domain. The path is a
250
- filesystem path name. It gets truncated to ` sizeof(sockaddr_un.sun_path) `
251
- bytes, decreased by 1. It varies on different operating system between 91 and
252
- 107 bytes. The typical values are 107 on Linux and 103 on OS X. The path is
253
- subject to the same naming conventions and permissions checks as would be done
254
- on file creation, will be visible in the filesystem, and will * persist until
255
- unlinked* .
256
-
257
- On Windows, the local domain is implemented using a named pipe. The path * must*
258
- refer to an entry in ` \\?\pipe\ ` or ` \\.\pipe\ ` . Any characters are permitted,
259
- but the latter may do some processing of pipe names, such as resolving ` .. `
260
- sequences. Despite appearances, the pipe name space is flat. Pipes will * not
261
- persist* , they are removed when the last reference to them is closed. Do not
262
- forget JavaScript string escaping requires paths to be specified with
263
- double-backslashes, such as:
264
-
265
- ``` js
266
- net .createServer ().listen (
267
- path .join (' \\\\ ?\\ pipe' , process .cwd (), ' myctl' ))
268
- ```
269
-
270
275
#### server.listen([ port] [ , host ] [ , backlog] [ , callback ] )
271
276
<!-- YAML
272
277
added: v0.1.90
@@ -566,10 +571,12 @@ For TCP connections, available `options` are:
566
571
For [ IPC] [ ] connections, available ` options ` are:
567
572
568
573
* ` path ` {string} Required. Path the client should connect to.
574
+ See [ Identifying paths for IPC connections] [ ] .
569
575
570
576
#### socket.connect(path[ , connectListener] )
571
577
572
- * ` path ` {string} Path the client should connect to.
578
+ * ` path ` {string} Path the client should connect to. See
579
+ [ Identifying paths for IPC connections] [ ] .
573
580
* ` connectListener ` {Function} Common parameter of [ ` socket.connect() ` ] [ ]
574
581
methods. Will be added as a listener for the [ ` 'connect' ` ] [ ] event once.
575
582
* Returns: {net.Socket} The socket itself.
@@ -895,6 +902,7 @@ added: v0.1.90
895
902
896
903
* ` path ` {string} Path the socket should connect to. Will be passed to
897
904
[ ` socket.connect(path[, connectListener]) ` ] [ `socket.connect(path)` ] .
905
+ See [ Identifying paths for IPC connections] [ ] .
898
906
* ` connectListener ` {Function} Common parameter of the
899
907
[ ` net.createConnection() ` ] [ ] functions, an "once" listener for the
900
908
` 'connect' ` event on the initiating socket. Will be passed to
@@ -1074,6 +1082,7 @@ Returns true if input is a version 6 IP address, otherwise returns false.
1074
1082
[ `stream.setEncoding()` ] : stream.html#stream_readable_setencoding_encoding
1075
1083
[ duplex stream ] : stream.html#stream_class_stream_duplex
1076
1084
[ half-closed ] : https://tools.ietf.org/html/rfc1122#section-4.2.2.13
1085
+ [ Identifying paths for IPC connections ] : #net_identifying_paths_for_ipc_connections
1077
1086
[ IPC ] : #net_ipc_support
1078
1087
[ Readable Stream ] : stream.html#stream_class_stream_readable
1079
1088
[ socket(7) ] : http://man7.org/linux/man-pages/man7/socket.7.html
0 commit comments