@@ -17,7 +17,31 @@ const net = require('net');
1717The ` net ` module supports IPC with named pipes on Windows, and UNIX domain
1818sockets on other operating systems.
1919
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+ ```
2145
2246## Class: net.Server
2347<!-- YAML
@@ -206,13 +230,14 @@ added: v0.11.14
206230-->
207231
208232* ` 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() ` ] [ ]
213238 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() ` ] [ ]
216241 functions
217242
218243If ` port ` is specified, it behaves the same as
@@ -240,33 +265,13 @@ server.listen({
240265added: v0.1.90
241266-->
242267
243- * ` path ` {string}
268+ * ` path ` {String} Path the server should listen to. See
269+ [ Identifying paths for IPC connections] [ ] .
244270* ` backlog ` {number} Common parameter of [ ` server.listen() ` ] [ ] functions
245271* ` callback ` {Function} Common parameter of [ ` server.listen() ` ] [ ] functions
246272
247273Start a [ IPC] [ ] server listening for connections on the given ` path ` .
248274
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-
270275#### server.listen([ port] [ , host ] [ , backlog] [ , callback ] )
271276<!-- YAML
272277added: v0.1.90
@@ -566,10 +571,12 @@ For TCP connections, available `options` are:
566571For [ IPC] [ ] connections, available ` options ` are:
567572
568573* ` path ` {string} Required. Path the client should connect to.
574+ See [ Identifying paths for IPC connections] [ ] .
569575
570576#### socket.connect(path[ , connectListener] )
571577
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] [ ] .
573580* ` connectListener ` {Function} Common parameter of [ ` socket.connect() ` ] [ ]
574581 methods. Will be added as a listener for the [ ` 'connect' ` ] [ ] event once.
575582* Returns: {net.Socket} The socket itself.
@@ -895,6 +902,7 @@ added: v0.1.90
895902
896903* ` path ` {string} Path the socket should connect to. Will be passed to
897904 [ ` socket.connect(path[, connectListener]) ` ] [ `socket.connect(path)` ] .
905+ See [ Identifying paths for IPC connections] [ ] .
898906* ` connectListener ` {Function} Common parameter of the
899907 [ ` net.createConnection() ` ] [ ] functions, an "once" listener for the
900908 ` '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.
10741082[ `stream.setEncoding()` ] : stream.html#stream_readable_setencoding_encoding
10751083[ duplex stream ] : stream.html#stream_class_stream_duplex
10761084[ 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
10771086[ IPC ] : #net_ipc_support
10781087[ Readable Stream ] : stream.html#stream_class_stream_readable
10791088[ socket(7) ] : http://man7.org/linux/man-pages/man7/socket.7.html
0 commit comments