{
  "type": "module",
  "source": "doc/api/net.md",
  "modules": [
    {
      "textRaw": "Net",
      "name": "net",
      "introduced_in": "v0.10.0",
      "type": "module",
      "stability": 2,
      "stabilityText": "Stable",
      "desc": "<p>The <code>node:net</code> module provides an asynchronous network API for creating stream-based\nTCP or <a href=\"#ipc-support\">IPC</a> servers (<a href=\"#netcreateserveroptions-connectionlistener\"><code>net.createServer()</code></a>) and clients\n(<a href=\"#netcreateconnection\"><code>net.createConnection()</code></a>).</p>\n<p>It can be accessed using:</p>\n<pre><code class=\"language-mjs\">import net from 'node:net';\n</code></pre>\n<pre><code class=\"language-cjs\">const net = require('node:net');\n</code></pre>",
      "modules": [
        {
          "textRaw": "IPC support",
          "name": "ipc_support",
          "type": "module",
          "meta": {
            "changes": [
              {
                "version": "v20.8.0",
                "pr-url": "https://github.com/nodejs/node/pull/49667",
                "description": "Support binding to abstract Unix domain socket path like `\\0abstract`. We can bind '\\0' for Node.js `< v20.4.0`."
              }
            ]
          },
          "desc": "<p>The <code>node:net</code> module supports IPC with named pipes on Windows, and Unix domain\nsockets on other operating systems.</p>",
          "modules": [
            {
              "textRaw": "Identifying paths for IPC connections",
              "name": "identifying_paths_for_ipc_connections",
              "type": "module",
              "desc": "<p><a href=\"#netconnect\"><code>net.connect()</code></a>, <a href=\"#netcreateconnection\"><code>net.createConnection()</code></a>, <a href=\"#serverlisten\"><code>server.listen()</code></a>, and\n<a href=\"#socketconnect\"><code>socket.connect()</code></a> take a <code>path</code> parameter to identify IPC endpoints.</p>\n<p>On Unix, the local domain is also known as the Unix domain. The path is a\nfile system pathname. It will throw an error when the length of pathname is\ngreater than the length of <code>sizeof(sockaddr_un.sun_path)</code>. Typical values are\n107 bytes on Linux and 103 bytes on macOS. If a Node.js API abstraction creates\nthe Unix domain socket, it will unlink the Unix domain socket as well. For\nexample, <a href=\"#netcreateserveroptions-connectionlistener\"><code>net.createServer()</code></a> may create a Unix domain socket and\n<a href=\"#serverclosecallback\"><code>server.close()</code></a> will unlink it. But if a user creates the Unix domain\nsocket outside of these abstractions, the user will need to remove it. The same\napplies when a Node.js API creates a Unix domain socket but the program then\ncrashes. In short, a Unix domain socket will be visible in the file system and\nwill persist until unlinked. On Linux, You can use Unix abstract socket by adding\n<code>\\0</code> to the beginning of the path, such as <code>\\0abstract</code>. The path to the Unix\nabstract socket is not visible in the file system and it will disappear automatically\nwhen all open references to the socket are closed.</p>\n<p>On Windows, the local domain is implemented using a named pipe. The path <em>must</em>\nrefer to an entry in <code>\\\\?\\pipe\\</code> or <code>\\\\.\\pipe\\</code>. Any characters are permitted,\nbut the latter may do some processing of pipe names, such as resolving <code>..</code>\nsequences. Despite how it might look, the pipe namespace is flat. Pipes will\n<em>not persist</em>. They are removed when the last reference to them is closed.\nUnlike Unix domain sockets, Windows will close and remove the pipe when the\nowning process exits.</p>\n<p>JavaScript string escaping requires paths to be specified with extra backslash\nescaping such as:</p>\n<pre><code class=\"language-js\">net.createServer().listen(\n  path.join('\\\\\\\\?\\\\pipe', process.cwd(), 'myctl'));\n</code></pre>",
              "displayName": "Identifying paths for IPC connections"
            }
          ],
          "displayName": "IPC support"
        }
      ],
      "classes": [
        {
          "textRaw": "Class: `net.BlockList`",
          "name": "net.BlockList",
          "type": "class",
          "meta": {
            "added": [
              "v15.0.0",
              "v14.18.0"
            ],
            "changes": []
          },
          "desc": "<p>The <code>BlockList</code> object can be used with some network APIs to specify rules for\ndisabling inbound or outbound access to specific IP addresses, IP ranges, or\nIP subnets.</p>",
          "methods": [
            {
              "textRaw": "`blockList.addAddress(address[, type])`",
              "name": "addAddress",
              "type": "method",
              "meta": {
                "added": [
                  "v15.0.0",
                  "v14.18.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`address` {string|net.SocketAddress} An IPv4 or IPv6 address.",
                      "name": "address",
                      "type": "string|net.SocketAddress",
                      "desc": "An IPv4 or IPv6 address."
                    },
                    {
                      "textRaw": "`type` {string} Either `'ipv4'` or `'ipv6'`. **Default:** `'ipv4'`.",
                      "name": "type",
                      "type": "string",
                      "default": "`'ipv4'`",
                      "desc": "Either `'ipv4'` or `'ipv6'`.",
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>Adds a rule to block the given IP address.</p>"
            },
            {
              "textRaw": "`blockList.addRange(start, end[, type])`",
              "name": "addRange",
              "type": "method",
              "meta": {
                "added": [
                  "v15.0.0",
                  "v14.18.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`start` {string|net.SocketAddress} The starting IPv4 or IPv6 address in the range.",
                      "name": "start",
                      "type": "string|net.SocketAddress",
                      "desc": "The starting IPv4 or IPv6 address in the range."
                    },
                    {
                      "textRaw": "`end` {string|net.SocketAddress} The ending IPv4 or IPv6 address in the range.",
                      "name": "end",
                      "type": "string|net.SocketAddress",
                      "desc": "The ending IPv4 or IPv6 address in the range."
                    },
                    {
                      "textRaw": "`type` {string} Either `'ipv4'` or `'ipv6'`. **Default:** `'ipv4'`.",
                      "name": "type",
                      "type": "string",
                      "default": "`'ipv4'`",
                      "desc": "Either `'ipv4'` or `'ipv6'`.",
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>Adds a rule to block a range of IP addresses from <code>start</code> (inclusive) to\n<code>end</code> (inclusive).</p>"
            },
            {
              "textRaw": "`blockList.addSubnet(net, prefix[, type])`",
              "name": "addSubnet",
              "type": "method",
              "meta": {
                "added": [
                  "v15.0.0",
                  "v14.18.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`net` {string|net.SocketAddress} The network IPv4 or IPv6 address.",
                      "name": "net",
                      "type": "string|net.SocketAddress",
                      "desc": "The network IPv4 or IPv6 address."
                    },
                    {
                      "textRaw": "`prefix` {number} The number of CIDR prefix bits. For IPv4, this must be a value between `0` and `32`. For IPv6, this must be between `0` and `128`.",
                      "name": "prefix",
                      "type": "number",
                      "desc": "The number of CIDR prefix bits. For IPv4, this must be a value between `0` and `32`. For IPv6, this must be between `0` and `128`."
                    },
                    {
                      "textRaw": "`type` {string} Either `'ipv4'` or `'ipv6'`. **Default:** `'ipv4'`.",
                      "name": "type",
                      "type": "string",
                      "default": "`'ipv4'`",
                      "desc": "Either `'ipv4'` or `'ipv6'`.",
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>Adds a rule to block a range of IP addresses specified as a subnet mask.</p>"
            },
            {
              "textRaw": "`blockList.check(address[, type])`",
              "name": "check",
              "type": "method",
              "meta": {
                "added": [
                  "v15.0.0",
                  "v14.18.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`address` {string|net.SocketAddress} The IP address to check",
                      "name": "address",
                      "type": "string|net.SocketAddress",
                      "desc": "The IP address to check"
                    },
                    {
                      "textRaw": "`type` {string} Either `'ipv4'` or `'ipv6'`. **Default:** `'ipv4'`.",
                      "name": "type",
                      "type": "string",
                      "default": "`'ipv4'`",
                      "desc": "Either `'ipv4'` or `'ipv6'`.",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {boolean}",
                    "name": "return",
                    "type": "boolean"
                  }
                }
              ],
              "desc": "<p>Returns <code>true</code> if the given IP address matches any of the rules added to the\n<code>BlockList</code>.</p>\n<pre><code class=\"language-js\">const blockList = new net.BlockList();\nblockList.addAddress('123.123.123.123');\nblockList.addRange('10.0.0.1', '10.0.0.10');\nblockList.addSubnet('8592:757c:efae:4e45::', 64, 'ipv6');\n\nconsole.log(blockList.check('123.123.123.123'));  // Prints: true\nconsole.log(blockList.check('10.0.0.3'));  // Prints: true\nconsole.log(blockList.check('222.111.111.222'));  // Prints: false\n\n// IPv6 notation for IPv4 addresses works:\nconsole.log(blockList.check('::ffff:7b7b:7b7b', 'ipv6')); // Prints: true\nconsole.log(blockList.check('::ffff:123.123.123.123', 'ipv6')); // Prints: true\n</code></pre>"
            },
            {
              "textRaw": "`BlockList.isBlockList(value)`",
              "name": "isBlockList",
              "type": "method",
              "meta": {
                "added": [
                  "v23.4.0",
                  "v22.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`value` {any} Any JS value",
                      "name": "value",
                      "type": "any",
                      "desc": "Any JS value"
                    }
                  ],
                  "return": {
                    "textRaw": "Returns `true` if the `value` is a `net.BlockList`.",
                    "name": "return",
                    "desc": "`true` if the `value` is a `net.BlockList`."
                  }
                }
              ]
            },
            {
              "textRaw": "`blockList.fromJSON(value)`",
              "name": "fromJSON",
              "type": "method",
              "stability": 1,
              "stabilityText": "Experimental",
              "signatures": [
                {
                  "params": [
                    {
                      "name": "value"
                    }
                  ]
                }
              ],
              "desc": " <!-- YAML\nadded:\n - v24.5.0\n - v22.19.0\n-->\n<pre><code class=\"language-js\">const blockList = new net.BlockList();\nconst data = [\n  'Subnet: IPv4 192.168.1.0/24',\n  'Address: IPv4 10.0.0.5',\n  'Range: IPv4 192.168.2.1-192.168.2.10',\n  'Range: IPv4 10.0.0.1-10.0.0.10',\n];\nblockList.fromJSON(data);\nblockList.fromJSON(JSON.stringify(data));\n</code></pre>\n<ul>\n<li><code>value</code> Blocklist.rules</li>\n</ul>"
            },
            {
              "textRaw": "`blockList.toJSON()`",
              "name": "toJSON",
              "type": "method",
              "stability": 1,
              "stabilityText": "Experimental",
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns Blocklist.rules",
                    "name": "return",
                    "desc": "Blocklist.rules"
                  }
                }
              ],
              "desc": " <!-- YAML\nadded:\n - v24.5.0\n - v22.19.0\n-->"
            }
          ],
          "properties": [
            {
              "textRaw": "Type: {string[]}",
              "name": "rules",
              "type": "string[]",
              "meta": {
                "added": [
                  "v15.0.0",
                  "v14.18.0"
                ],
                "changes": []
              },
              "desc": "<p>The list of rules added to the blocklist.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `net.SocketAddress`",
          "name": "net.SocketAddress",
          "type": "class",
          "meta": {
            "added": [
              "v15.14.0",
              "v14.18.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "textRaw": "`new net.SocketAddress([options])`",
              "name": "net.SocketAddress",
              "type": "ctor",
              "meta": {
                "added": [
                  "v15.14.0",
                  "v14.18.0"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`options` {Object}",
                  "name": "options",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`address` {string} The network address as either an IPv4 or IPv6 string. **Default**: `'127.0.0.1'` if `family` is `'ipv4'`; `'::'` if `family` is `'ipv6'`.",
                      "name": "address",
                      "type": "string",
                      "desc": "The network address as either an IPv4 or IPv6 string. **Default**: `'127.0.0.1'` if `family` is `'ipv4'`; `'::'` if `family` is `'ipv6'`."
                    },
                    {
                      "textRaw": "`family` {string} One of either `'ipv4'` or `'ipv6'`. **Default**: `'ipv4'`.",
                      "name": "family",
                      "type": "string",
                      "desc": "One of either `'ipv4'` or `'ipv6'`. **Default**: `'ipv4'`."
                    },
                    {
                      "textRaw": "`flowlabel` {number} An IPv6 flow-label used only if `family` is `'ipv6'`.",
                      "name": "flowlabel",
                      "type": "number",
                      "desc": "An IPv6 flow-label used only if `family` is `'ipv6'`."
                    },
                    {
                      "textRaw": "`port` {number} An IP port.",
                      "name": "port",
                      "type": "number",
                      "desc": "An IP port."
                    }
                  ],
                  "optional": true
                }
              ]
            }
          ],
          "properties": [
            {
              "textRaw": "Type: {string}",
              "name": "address",
              "type": "string",
              "meta": {
                "added": [
                  "v15.14.0",
                  "v14.18.0"
                ],
                "changes": []
              }
            },
            {
              "textRaw": "Type: {string} Either `'ipv4'` or `'ipv6'`.",
              "name": "family",
              "type": "string",
              "meta": {
                "added": [
                  "v15.14.0",
                  "v14.18.0"
                ],
                "changes": []
              },
              "desc": "Either `'ipv4'` or `'ipv6'`."
            },
            {
              "textRaw": "Type: {number}",
              "name": "flowlabel",
              "type": "number",
              "meta": {
                "added": [
                  "v15.14.0",
                  "v14.18.0"
                ],
                "changes": []
              }
            },
            {
              "textRaw": "Type: {number}",
              "name": "port",
              "type": "number",
              "meta": {
                "added": [
                  "v15.14.0",
                  "v14.18.0"
                ],
                "changes": []
              }
            }
          ],
          "methods": [
            {
              "textRaw": "`SocketAddress.parse(input)`",
              "name": "parse",
              "type": "method",
              "meta": {
                "added": [
                  "v23.4.0",
                  "v22.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`input` {string} An input string containing an IP address and optional port, e.g. `123.1.2.3:1234` or `[1::1]:1234`.",
                      "name": "input",
                      "type": "string",
                      "desc": "An input string containing an IP address and optional port, e.g. `123.1.2.3:1234` or `[1::1]:1234`."
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {net.SocketAddress} Returns a `SocketAddress` if parsing was successful. Otherwise returns `undefined`.",
                    "name": "return",
                    "type": "net.SocketAddress",
                    "desc": "Returns a `SocketAddress` if parsing was successful. Otherwise returns `undefined`."
                  }
                }
              ]
            }
          ]
        },
        {
          "textRaw": "Class: `net.Server`",
          "name": "net.Server",
          "type": "class",
          "meta": {
            "added": [
              "v0.1.90"
            ],
            "changes": []
          },
          "desc": "<ul>\n<li>Extends: <a href=\"events.html#class-eventemitter\"><code>&#x3C;EventEmitter></code></a></li>\n</ul>\n<p>This class is used to create a TCP or <a href=\"#ipc-support\">IPC</a> server.</p>",
          "signatures": [
            {
              "textRaw": "`new net.Server([options][, connectionListener])`",
              "name": "net.Server",
              "type": "ctor",
              "params": [
                {
                  "textRaw": "`options` {Object} See `net.createServer([options][, connectionListener])`.",
                  "name": "options",
                  "type": "Object",
                  "desc": "See `net.createServer([options][, connectionListener])`.",
                  "optional": true
                },
                {
                  "textRaw": "`connectionListener` {Function} Automatically set as a listener for the `'connection'` event.",
                  "name": "connectionListener",
                  "type": "Function",
                  "desc": "Automatically set as a listener for the `'connection'` event.",
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {net.Server}",
                "name": "return",
                "type": "net.Server"
              },
              "desc": "<p><code>net.Server</code> is an <a href=\"events.html#class-eventemitter\"><code>EventEmitter</code></a> with the following events:</p>"
            }
          ],
          "events": [
            {
              "textRaw": "Event: `'close'`",
              "name": "close",
              "type": "event",
              "meta": {
                "added": [
                  "v0.5.0"
                ],
                "changes": []
              },
              "params": [],
              "desc": "<p>Emitted when the server closes. If connections exist, this\nevent is not emitted until all connections are ended.</p>"
            },
            {
              "textRaw": "Event: `'connection'`",
              "name": "connection",
              "type": "event",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "Type: {net.Socket} The connection object",
                  "name": "type",
                  "type": "net.Socket",
                  "desc": "The connection object"
                }
              ],
              "desc": "<p>Emitted when a new connection is made. <code>socket</code> is an instance of\n<code>net.Socket</code>.</p>"
            },
            {
              "textRaw": "Event: `'error'`",
              "name": "error",
              "type": "event",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "Type: {Error}",
                  "name": "type",
                  "type": "Error"
                }
              ],
              "desc": "<p>Emitted when an error occurs. Unlike <a href=\"#class-netsocket\"><code>net.Socket</code></a>, the <a href=\"#event-close\"><code>'close'</code></a>\nevent will <strong>not</strong> be emitted directly following this event unless\n<a href=\"#serverclosecallback\"><code>server.close()</code></a> is manually called. See the example in discussion of\n<a href=\"#serverlisten\"><code>server.listen()</code></a>.</p>"
            },
            {
              "textRaw": "Event: `'listening'`",
              "name": "listening",
              "type": "event",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "params": [],
              "desc": "<p>Emitted when the server has been bound after calling <a href=\"#serverlisten\"><code>server.listen()</code></a>.</p>"
            },
            {
              "textRaw": "Event: `'drop'`",
              "name": "drop",
              "type": "event",
              "meta": {
                "added": [
                  "v18.6.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`data` {Object} The argument passed to event listener.",
                  "name": "data",
                  "type": "Object",
                  "desc": "The argument passed to event listener.",
                  "options": [
                    {
                      "textRaw": "`localAddress` {string} Local address.",
                      "name": "localAddress",
                      "type": "string",
                      "desc": "Local address."
                    },
                    {
                      "textRaw": "`localPort` {number} Local port.",
                      "name": "localPort",
                      "type": "number",
                      "desc": "Local port."
                    },
                    {
                      "textRaw": "`localFamily` {string} Local family.",
                      "name": "localFamily",
                      "type": "string",
                      "desc": "Local family."
                    },
                    {
                      "textRaw": "`remoteAddress` {string} Remote address.",
                      "name": "remoteAddress",
                      "type": "string",
                      "desc": "Remote address."
                    },
                    {
                      "textRaw": "`remotePort` {number} Remote port.",
                      "name": "remotePort",
                      "type": "number",
                      "desc": "Remote port."
                    },
                    {
                      "textRaw": "`remoteFamily` {string} Remote IP family. `'IPv4'` or `'IPv6'`.",
                      "name": "remoteFamily",
                      "type": "string",
                      "desc": "Remote IP family. `'IPv4'` or `'IPv6'`."
                    }
                  ]
                }
              ],
              "desc": "<p>When the number of connections reaches the threshold of <code>server.maxConnections</code>,\nthe server will drop new connections and emit <code>'drop'</code> event instead. If it is a\nTCP server, the argument is as follows, otherwise the argument is <code>undefined</code>.</p>"
            }
          ],
          "methods": [
            {
              "textRaw": "`server.address()`",
              "name": "address",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": [
                  {
                    "version": "v18.4.0",
                    "pr-url": "https://github.com/nodejs/node/pull/43054",
                    "description": "The `family` property now returns a string instead of a number."
                  },
                  {
                    "version": "v18.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/41431",
                    "description": "The `family` property now returns a number instead of a string."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {Object|string|null}",
                    "name": "return",
                    "type": "Object|string|null"
                  }
                }
              ],
              "desc": "<p>Returns the bound <code>address</code>, the address <code>family</code> name, and <code>port</code> of the server\nas reported by the operating system if listening on an IP socket\n(useful to find which port was assigned when getting an OS-assigned address):\n<code>{ port: 12346, family: 'IPv4', address: '127.0.0.1' }</code>.</p>\n<p>For a server listening on a pipe or Unix domain socket, the name is returned\nas a string.</p>\n<pre><code class=\"language-js\">const server = net.createServer((socket) => {\n  socket.end('goodbye\\n');\n}).on('error', (err) => {\n  // Handle errors here.\n  throw err;\n});\n\n// Grab an arbitrary unused port.\nserver.listen(() => {\n  console.log('opened server on', server.address());\n});\n</code></pre>\n<p><code>server.address()</code> returns <code>null</code> before the <code>'listening'</code> event has been\nemitted or after calling <code>server.close()</code>.</p>"
            },
            {
              "textRaw": "`server.close([callback])`",
              "name": "close",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`callback` {Function} Called when the server is closed.",
                      "name": "callback",
                      "type": "Function",
                      "desc": "Called when the server is closed.",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {net.Server}",
                    "name": "return",
                    "type": "net.Server"
                  }
                }
              ],
              "desc": "<p>Stops the server from accepting new connections and keeps existing\nconnections. This function is asynchronous, the server is finally closed\nwhen all connections are ended and the server emits a <a href=\"#event-close\"><code>'close'</code></a> event.\nThe optional <code>callback</code> will be called once the <code>'close'</code> event occurs. Unlike\nthat event, it will be called with an <code>Error</code> as its only argument if the server\nwas not open when it was closed.</p>"
            },
            {
              "textRaw": "`server[Symbol.asyncDispose]()`",
              "name": "[Symbol.asyncDispose]",
              "type": "method",
              "meta": {
                "added": [
                  "v20.5.0",
                  "v18.18.0"
                ],
                "changes": [
                  {
                    "version": "v24.2.0",
                    "pr-url": "https://github.com/nodejs/node/pull/58467",
                    "description": "No longer experimental."
                  }
                ]
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Calls <a href=\"#serverclosecallback\"><code>server.close()</code></a> and returns a promise that fulfills when the\nserver has closed.</p>"
            },
            {
              "textRaw": "`server.getConnections(callback)`",
              "name": "getConnections",
              "type": "method",
              "meta": {
                "added": [
                  "v0.9.7"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`callback` {Function}",
                      "name": "callback",
                      "type": "Function"
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {net.Server}",
                    "name": "return",
                    "type": "net.Server"
                  }
                }
              ],
              "desc": "<p>Asynchronously get the number of concurrent connections on the server. Works\nwhen sockets were sent to forks.</p>\n<p>Callback should take two arguments <code>err</code> and <code>count</code>.</p>"
            },
            {
              "textRaw": "`server.listen()`",
              "name": "listen",
              "type": "method",
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Start a server listening for connections. A <code>net.Server</code> can be a TCP or\nan <a href=\"#ipc-support\">IPC</a> server depending on what it listens to.</p>\n<p>Possible signatures:</p>\n<ul>\n<li><a href=\"#serverlistenhandle-backlog-callback\"><code>server.listen(handle[, backlog][, callback])</code></a></li>\n<li><a href=\"#serverlistenoptions-callback\"><code>server.listen(options[, callback])</code></a></li>\n<li><a href=\"#serverlistenpath-backlog-callback\"><code>server.listen(path[, backlog][, callback])</code></a>\nfor <a href=\"#ipc-support\">IPC</a> servers</li>\n<li><a href=\"#serverlistenport-host-backlog-callback\"><code>server.listen([port[, host[, backlog]]][, callback])</code></a>\nfor TCP servers</li>\n</ul>\n<p>This function is asynchronous. When the server starts listening, the\n<a href=\"#event-listening\"><code>'listening'</code></a> event will be emitted. The last parameter <code>callback</code>\nwill be added as a listener for the <a href=\"#event-listening\"><code>'listening'</code></a> event.</p>\n<p>All <code>listen()</code> methods can take a <code>backlog</code> parameter to specify the maximum\nlength of the queue of pending connections. The actual length will be determined\nby the OS through sysctl settings such as <code>tcp_max_syn_backlog</code> and <code>somaxconn</code>\non Linux. The default value of this parameter is 511 (not 512).</p>\n<p>All <a href=\"#class-netsocket\"><code>net.Socket</code></a> are set to <code>SO_REUSEADDR</code> (see <a href=\"https://man7.org/linux/man-pages/man7/socket.7.html\"><code>socket(7)</code></a> for\ndetails).</p>\n<p>The <code>server.listen()</code> method can be called again if and only if there was an\nerror during the first <code>server.listen()</code> call or <code>server.close()</code> has been\ncalled. Otherwise, an <code>ERR_SERVER_ALREADY_LISTEN</code> error will be thrown.</p>\n<p>One of the most common errors raised when listening is <code>EADDRINUSE</code>.\nThis happens when another server is already listening on the requested\n<code>port</code>/<code>path</code>/<code>handle</code>. One way to handle this would be to retry\nafter a certain amount of time:</p>\n<pre><code class=\"language-js\">server.on('error', (e) => {\n  if (e.code === 'EADDRINUSE') {\n    console.error('Address in use, retrying...');\n    setTimeout(() => {\n      server.close();\n      server.listen(PORT, HOST);\n    }, 1000);\n  }\n});\n</code></pre>",
              "methods": [
                {
                  "textRaw": "`server.listen(handle[, backlog][, callback])`",
                  "name": "listen",
                  "type": "method",
                  "meta": {
                    "added": [
                      "v0.5.10"
                    ],
                    "changes": []
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`handle` {Object}",
                          "name": "handle",
                          "type": "Object"
                        },
                        {
                          "textRaw": "`backlog` {number} Common parameter of `server.listen()` functions",
                          "name": "backlog",
                          "type": "number",
                          "desc": "Common parameter of `server.listen()` functions",
                          "optional": true
                        },
                        {
                          "textRaw": "`callback` {Function}",
                          "name": "callback",
                          "type": "Function",
                          "optional": true
                        }
                      ],
                      "return": {
                        "textRaw": "Returns: {net.Server}",
                        "name": "return",
                        "type": "net.Server"
                      }
                    }
                  ],
                  "desc": "<p>Start a server listening for connections on a given <code>handle</code> that has\nalready been bound to a port, a Unix domain socket, or a Windows named pipe.</p>\n<p>The <code>handle</code> object can be either a server, a socket (anything with an\nunderlying <code>_handle</code> member), or an object with an <code>fd</code> member that is a\nvalid file descriptor.</p>\n<p>Listening on a file descriptor is not supported on Windows.</p>"
                },
                {
                  "textRaw": "`server.listen(options[, callback])`",
                  "name": "listen",
                  "type": "method",
                  "meta": {
                    "added": [
                      "v0.11.14"
                    ],
                    "changes": [
                      {
                        "version": [
                          "v23.1.0",
                          "v22.12.0"
                        ],
                        "pr-url": "https://github.com/nodejs/node/pull/55408",
                        "description": "The `reusePort` option is supported."
                      },
                      {
                        "version": "v15.6.0",
                        "pr-url": "https://github.com/nodejs/node/pull/36623",
                        "description": "AbortSignal support was added."
                      },
                      {
                        "version": "v11.4.0",
                        "pr-url": "https://github.com/nodejs/node/pull/23798",
                        "description": "The `ipv6Only` option is supported."
                      }
                    ]
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`options` {Object} Required. Supports the following properties:",
                          "name": "options",
                          "type": "Object",
                          "desc": "Required. Supports the following properties:",
                          "options": [
                            {
                              "textRaw": "`backlog` {number} Common parameter of `server.listen()` functions.",
                              "name": "backlog",
                              "type": "number",
                              "desc": "Common parameter of `server.listen()` functions."
                            },
                            {
                              "textRaw": "`exclusive` {boolean} **Default:** `false`",
                              "name": "exclusive",
                              "type": "boolean",
                              "default": "`false`"
                            },
                            {
                              "textRaw": "`host` {string}",
                              "name": "host",
                              "type": "string"
                            },
                            {
                              "textRaw": "`ipv6Only` {boolean} For TCP servers, setting `ipv6Only` to `true` will disable dual-stack support, i.e., binding to host `::` won't make `0.0.0.0` be bound. **Default:** `false`.",
                              "name": "ipv6Only",
                              "type": "boolean",
                              "default": "`false`",
                              "desc": "For TCP servers, setting `ipv6Only` to `true` will disable dual-stack support, i.e., binding to host `::` won't make `0.0.0.0` be bound."
                            },
                            {
                              "textRaw": "`reusePort` {boolean} For TCP servers, setting `reusePort` to `true` allows multiple sockets on the same host to bind to the same port. Incoming connections are distributed by the operating system to listening sockets. This option is available only on some platforms, such as Linux 3.9+, DragonFlyBSD 3.6+, FreeBSD 12.0+, Solaris 11.4, and AIX 7.2.5+. On unsupported platforms, this option raises an error. **Default:** `false`.",
                              "name": "reusePort",
                              "type": "boolean",
                              "default": "`false`",
                              "desc": "For TCP servers, setting `reusePort` to `true` allows multiple sockets on the same host to bind to the same port. Incoming connections are distributed by the operating system to listening sockets. This option is available only on some platforms, such as Linux 3.9+, DragonFlyBSD 3.6+, FreeBSD 12.0+, Solaris 11.4, and AIX 7.2.5+. On unsupported platforms, this option raises an error."
                            },
                            {
                              "textRaw": "`path` {string} Will be ignored if `port` is specified. See Identifying paths for IPC connections.",
                              "name": "path",
                              "type": "string",
                              "desc": "Will be ignored if `port` is specified. See Identifying paths for IPC connections."
                            },
                            {
                              "textRaw": "`port` {number}",
                              "name": "port",
                              "type": "number"
                            },
                            {
                              "textRaw": "`readableAll` {boolean} For IPC servers makes the pipe readable for all users. **Default:** `false`.",
                              "name": "readableAll",
                              "type": "boolean",
                              "default": "`false`",
                              "desc": "For IPC servers makes the pipe readable for all users."
                            },
                            {
                              "textRaw": "`signal` {AbortSignal} An AbortSignal that may be used to close a listening server.",
                              "name": "signal",
                              "type": "AbortSignal",
                              "desc": "An AbortSignal that may be used to close a listening server."
                            },
                            {
                              "textRaw": "`writableAll` {boolean} For IPC servers makes the pipe writable for all users. **Default:** `false`.",
                              "name": "writableAll",
                              "type": "boolean",
                              "default": "`false`",
                              "desc": "For IPC servers makes the pipe writable for all users."
                            }
                          ]
                        },
                        {
                          "textRaw": "`callback` {Function} functions.",
                          "name": "callback",
                          "type": "Function",
                          "desc": "functions.",
                          "optional": true
                        }
                      ],
                      "return": {
                        "textRaw": "Returns: {net.Server}",
                        "name": "return",
                        "type": "net.Server"
                      }
                    }
                  ],
                  "desc": "<p>If <code>port</code> is specified, it behaves the same as\n<a href=\"#serverlistenport-host-backlog-callback\"><code>server.listen([port[, host[, backlog]]][, callback])</code></a>.\nOtherwise, if <code>path</code> is specified, it behaves the same as\n<a href=\"#serverlistenpath-backlog-callback\"><code>server.listen(path[, backlog][, callback])</code></a>.\nIf none of them is specified, an error will be thrown.</p>\n<p>If <code>exclusive</code> is <code>false</code> (default), then cluster workers will use the same\nunderlying handle, allowing connection handling duties to be shared. When\n<code>exclusive</code> is <code>true</code>, the handle is not shared, and attempted port sharing\nresults in an error. An example which listens on an exclusive port is\nshown below.</p>\n<pre><code class=\"language-js\">server.listen({\n  host: 'localhost',\n  port: 80,\n  exclusive: true,\n});\n</code></pre>\n<p>When <code>exclusive</code> is <code>true</code> and the underlying handle is shared, it is\npossible that several workers query a handle with different backlogs.\nIn this case, the first <code>backlog</code> passed to the master process will be used.</p>\n<p>Starting an IPC server as root may cause the server path to be inaccessible for\nunprivileged users. Using <code>readableAll</code> and <code>writableAll</code> will make the server\naccessible for all users.</p>\n<p>If the <code>signal</code> option is enabled, calling <code>.abort()</code> on the corresponding\n<code>AbortController</code> is similar to calling <code>.close()</code> on the server:</p>\n<pre><code class=\"language-js\">const controller = new AbortController();\nserver.listen({\n  host: 'localhost',\n  port: 80,\n  signal: controller.signal,\n});\n// Later, when you want to close the server.\ncontroller.abort();\n</code></pre>"
                },
                {
                  "textRaw": "`server.listen(path[, backlog][, callback])`",
                  "name": "listen",
                  "type": "method",
                  "meta": {
                    "added": [
                      "v0.1.90"
                    ],
                    "changes": []
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`path` {string} Path the server should listen to. See Identifying paths for IPC connections.",
                          "name": "path",
                          "type": "string",
                          "desc": "Path the server should listen to. See Identifying paths for IPC connections."
                        },
                        {
                          "textRaw": "`backlog` {number} Common parameter of `server.listen()` functions.",
                          "name": "backlog",
                          "type": "number",
                          "desc": "Common parameter of `server.listen()` functions.",
                          "optional": true
                        },
                        {
                          "textRaw": "`callback` {Function}.",
                          "name": "callback",
                          "type": "Function",
                          "desc": ".",
                          "optional": true
                        }
                      ],
                      "return": {
                        "textRaw": "Returns: {net.Server}",
                        "name": "return",
                        "type": "net.Server"
                      }
                    }
                  ],
                  "desc": "<p>Start an <a href=\"#ipc-support\">IPC</a> server listening for connections on the given <code>path</code>.</p>"
                },
                {
                  "textRaw": "`server.listen([port[, host[, backlog]]][, callback])`",
                  "name": "listen",
                  "type": "method",
                  "meta": {
                    "added": [
                      "v0.1.90"
                    ],
                    "changes": []
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`port` {number}",
                          "name": "port",
                          "type": "number",
                          "optional": true
                        },
                        {
                          "textRaw": "`host` {string}",
                          "name": "host",
                          "type": "string",
                          "optional": true
                        },
                        {
                          "textRaw": "`backlog` {number} Common parameter of `server.listen()` functions.",
                          "name": "backlog",
                          "type": "number",
                          "desc": "Common parameter of `server.listen()` functions.",
                          "optional": true
                        },
                        {
                          "textRaw": "`callback` {Function}.",
                          "name": "callback",
                          "type": "Function",
                          "desc": ".",
                          "optional": true
                        }
                      ],
                      "return": {
                        "textRaw": "Returns: {net.Server}",
                        "name": "return",
                        "type": "net.Server"
                      }
                    }
                  ],
                  "desc": "<p>Start a TCP server listening for connections on the given <code>port</code> and <code>host</code>.</p>\n<p>If <code>port</code> is omitted or is 0, the operating system will assign an arbitrary\nunused port, which can be retrieved by using <code>server.address().port</code>\nafter the <a href=\"#event-listening\"><code>'listening'</code></a> event has been emitted.</p>\n<p>If <code>host</code> is omitted, the server will accept connections on the\n<a href=\"https://en.wikipedia.org/wiki/IPv6_address#Unspecified_address\">unspecified IPv6 address</a> (<code>::</code>) when IPv6 is available, or the\n<a href=\"https://en.wikipedia.org/wiki/0.0.0.0\">unspecified IPv4 address</a> (<code>0.0.0.0</code>) otherwise.</p>\n<p>In most operating systems, listening to the <a href=\"https://en.wikipedia.org/wiki/IPv6_address#Unspecified_address\">unspecified IPv6 address</a> (<code>::</code>)\nmay cause the <code>net.Server</code> to also listen on the <a href=\"https://en.wikipedia.org/wiki/0.0.0.0\">unspecified IPv4 address</a>\n(<code>0.0.0.0</code>).</p>"
                }
              ]
            },
            {
              "textRaw": "`server.ref()`",
              "name": "ref",
              "type": "method",
              "meta": {
                "added": [
                  "v0.9.1"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {net.Server}",
                    "name": "return",
                    "type": "net.Server"
                  }
                }
              ],
              "desc": "<p>Opposite of <code>unref()</code>, calling <code>ref()</code> on a previously <code>unref</code>ed server will\n<em>not</em> let the program exit if it's the only server left (the default behavior).\nIf the server is <code>ref</code>ed calling <code>ref()</code> again will have no effect.</p>"
            },
            {
              "textRaw": "`server.unref()`",
              "name": "unref",
              "type": "method",
              "meta": {
                "added": [
                  "v0.9.1"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {net.Server}",
                    "name": "return",
                    "type": "net.Server"
                  }
                }
              ],
              "desc": "<p>Calling <code>unref()</code> on a server will allow the program to exit if this is the only\nactive server in the event system. If the server is already <code>unref</code>ed calling\n<code>unref()</code> again will have no effect.</p>"
            }
          ],
          "properties": [
            {
              "textRaw": "Type: {boolean} Indicates whether or not the server is listening for connections.",
              "name": "listening",
              "type": "boolean",
              "meta": {
                "added": [
                  "v5.7.0"
                ],
                "changes": []
              },
              "desc": "Indicates whether or not the server is listening for connections."
            },
            {
              "textRaw": "Type: {integer}",
              "name": "maxConnections",
              "type": "integer",
              "meta": {
                "added": [
                  "v0.2.0"
                ],
                "changes": [
                  {
                    "version": "v21.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/48276",
                    "description": "Setting `maxConnections` to `0` drops all the incoming connections. Previously, it was interpreted as `Infinity`."
                  }
                ]
              },
              "desc": "<p>When the number of connections reaches the <code>server.maxConnections</code> threshold:</p>\n<ol>\n<li>\n<p>If the process is not running in cluster mode, Node.js will close the connection.</p>\n</li>\n<li>\n<p>If the process is running in cluster mode, Node.js will, by default, route the connection to another worker process. To close the connection instead, set <a href=\"#serverdropmaxconnection\"><code>server.dropMaxConnection</code></a> to <code>true</code>.</p>\n</li>\n</ol>\n<p>It is not recommended to use this option once a socket has been sent to a child\nwith <a href=\"child_process.html#child_processforkmodulepath-args-options\"><code>child_process.fork()</code></a>.</p>"
            },
            {
              "textRaw": "Type: {boolean}",
              "name": "dropMaxConnection",
              "type": "boolean",
              "meta": {
                "added": [
                  "v23.1.0",
                  "v22.12.0"
                ],
                "changes": []
              },
              "desc": "<p>Set this property to <code>true</code> to begin closing connections once the number of connections reaches the <a href=\"#servermaxconnections\"><code>server.maxConnections</code></a> threshold. This setting is only effective in cluster mode.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `net.Socket`",
          "name": "net.Socket",
          "type": "class",
          "meta": {
            "added": [
              "v0.3.4"
            ],
            "changes": []
          },
          "desc": "<ul>\n<li>Extends: <a href=\"stream.html#class-streamduplex\"><code>&#x3C;stream.Duplex></code></a></li>\n</ul>\n<p>This class is an abstraction of a TCP socket or a streaming <a href=\"#ipc-support\">IPC</a> endpoint\n(uses named pipes on Windows, and Unix domain sockets otherwise). It is also\nan <a href=\"events.html#class-eventemitter\"><code>EventEmitter</code></a>.</p>\n<p>A <code>net.Socket</code> can be created by the user and used directly to interact with\na server. For example, it is returned by <a href=\"#netcreateconnection\"><code>net.createConnection()</code></a>,\nso the user can use it to talk to the server.</p>\n<p>It can also be created by Node.js and passed to the user when a connection\nis received. For example, it is passed to the listeners of a\n<a href=\"#event-connection\"><code>'connection'</code></a> event emitted on a <a href=\"#class-netserver\"><code>net.Server</code></a>, so the user can use\nit to interact with the client.</p>",
          "signatures": [
            {
              "textRaw": "`new net.Socket([options])`",
              "name": "net.Socket",
              "type": "ctor",
              "meta": {
                "added": [
                  "v0.3.4"
                ],
                "changes": [
                  {
                    "version": "v25.6.0",
                    "pr-url": "https://github.com/nodejs/node/pull/61503",
                    "description": "Added `typeOfService` option."
                  },
                  {
                    "version": "v15.14.0",
                    "pr-url": "https://github.com/nodejs/node/pull/37735",
                    "description": "AbortSignal support was added."
                  },
                  {
                    "version": "v12.10.0",
                    "pr-url": "https://github.com/nodejs/node/pull/25436",
                    "description": "Added `onread` option."
                  }
                ]
              },
              "params": [
                {
                  "textRaw": "`options` {Object} Available options are:",
                  "name": "options",
                  "type": "Object",
                  "desc": "Available options are:",
                  "options": [
                    {
                      "textRaw": "`allowHalfOpen` {boolean} If set to `false`, then the socket will automatically end the writable side when the readable side ends. See `net.createServer()` and the `'end'` event for details. **Default:** `false`.",
                      "name": "allowHalfOpen",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If set to `false`, then the socket will automatically end the writable side when the readable side ends. See `net.createServer()` and the `'end'` event for details."
                    },
                    {
                      "textRaw": "`blockList` {net.BlockList} `blockList` can be used for disabling outbound access to specific IP addresses, IP ranges, or IP subnets.",
                      "name": "blockList",
                      "type": "net.BlockList",
                      "desc": "`blockList` can be used for disabling outbound access to specific IP addresses, IP ranges, or IP subnets."
                    },
                    {
                      "textRaw": "`fd` {number} If specified, wrap around an existing socket with the given file descriptor, otherwise a new socket will be created.",
                      "name": "fd",
                      "type": "number",
                      "desc": "If specified, wrap around an existing socket with the given file descriptor, otherwise a new socket will be created."
                    },
                    {
                      "textRaw": "`keepAlive` {boolean} If set to `true`, it enables keep-alive functionality on the socket immediately after the connection is established, similarly on what is done in `socket.setKeepAlive()`. **Default:** `false`.",
                      "name": "keepAlive",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If set to `true`, it enables keep-alive functionality on the socket immediately after the connection is established, similarly on what is done in `socket.setKeepAlive()`."
                    },
                    {
                      "textRaw": "`keepAliveInitialDelay` {number} If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket. **Default:** `0`.",
                      "name": "keepAliveInitialDelay",
                      "type": "number",
                      "default": "`0`",
                      "desc": "If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket."
                    },
                    {
                      "textRaw": "`noDelay` {boolean} If set to `true`, it disables the use of Nagle's algorithm immediately after the socket is established. **Default:** `false`.",
                      "name": "noDelay",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If set to `true`, it disables the use of Nagle's algorithm immediately after the socket is established."
                    },
                    {
                      "textRaw": "`onread` {Object} If specified, incoming data is stored in a single `buffer` and passed to the supplied `callback` when data arrives on the socket. This will cause the streaming functionality to not provide any data. The socket will emit events like `'error'`, `'end'`, and `'close'` as usual. Methods like `pause()` and `resume()` will also behave as expected.",
                      "name": "onread",
                      "type": "Object",
                      "desc": "If specified, incoming data is stored in a single `buffer` and passed to the supplied `callback` when data arrives on the socket. This will cause the streaming functionality to not provide any data. The socket will emit events like `'error'`, `'end'`, and `'close'` as usual. Methods like `pause()` and `resume()` will also behave as expected.",
                      "options": [
                        {
                          "textRaw": "`buffer` {Buffer|Uint8Array|Function} Either a reusable chunk of memory to use for storing incoming data or a function that returns such.",
                          "name": "buffer",
                          "type": "Buffer|Uint8Array|Function",
                          "desc": "Either a reusable chunk of memory to use for storing incoming data or a function that returns such."
                        },
                        {
                          "textRaw": "`callback` {Function} This function is called for every chunk of incoming data. Two arguments are passed to it: the number of bytes written to `buffer` and a reference to `buffer`. Return `false` from this function to implicitly `pause()` the socket. This function will be executed in the global context.",
                          "name": "callback",
                          "type": "Function",
                          "desc": "This function is called for every chunk of incoming data. Two arguments are passed to it: the number of bytes written to `buffer` and a reference to `buffer`. Return `false` from this function to implicitly `pause()` the socket. This function will be executed in the global context."
                        }
                      ]
                    },
                    {
                      "textRaw": "`readable` {boolean} Allow reads on the socket when an `fd` is passed, otherwise ignored. **Default:** `false`.",
                      "name": "readable",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "Allow reads on the socket when an `fd` is passed, otherwise ignored."
                    },
                    {
                      "textRaw": "`signal` {AbortSignal} An Abort signal that may be used to destroy the socket.",
                      "name": "signal",
                      "type": "AbortSignal",
                      "desc": "An Abort signal that may be used to destroy the socket."
                    },
                    {
                      "textRaw": "`typeOfService` {number} The initial Type of Service (TOS) value.",
                      "name": "typeOfService",
                      "type": "number",
                      "desc": "The initial Type of Service (TOS) value."
                    },
                    {
                      "textRaw": "`writable` {boolean} Allow writes on the socket when an `fd` is passed, otherwise ignored. **Default:** `false`.",
                      "name": "writable",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "Allow writes on the socket when an `fd` is passed, otherwise ignored."
                    }
                  ],
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {net.Socket}",
                "name": "return",
                "type": "net.Socket"
              },
              "desc": "<p>Creates a new socket object.</p>\n<p>The newly created socket can be either a TCP socket or a streaming <a href=\"#ipc-support\">IPC</a>\nendpoint, depending on what it <a href=\"#socketconnect\"><code>connect()</code></a> to.</p>"
            }
          ],
          "events": [
            {
              "textRaw": "Event: `'close'`",
              "name": "close",
              "type": "event",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`hadError` {boolean} `true` if the socket had a transmission error.",
                  "name": "hadError",
                  "type": "boolean",
                  "desc": "`true` if the socket had a transmission error."
                }
              ],
              "desc": "<p>Emitted once the socket is fully closed. The argument <code>hadError</code> is a boolean\nwhich says if the socket was closed due to a transmission error.</p>"
            },
            {
              "textRaw": "Event: `'connect'`",
              "name": "connect",
              "type": "event",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "params": [],
              "desc": "<p>Emitted when a socket connection is successfully established.\nSee <a href=\"#netcreateconnection\"><code>net.createConnection()</code></a>.</p>"
            },
            {
              "textRaw": "Event: `'connectionAttempt'`",
              "name": "connectionAttempt",
              "type": "event",
              "meta": {
                "added": [
                  "v21.6.0",
                  "v20.12.0"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`ip` {string} The IP which the socket is attempting to connect to.",
                  "name": "ip",
                  "type": "string",
                  "desc": "The IP which the socket is attempting to connect to."
                },
                {
                  "textRaw": "`port` {number} The port which the socket is attempting to connect to.",
                  "name": "port",
                  "type": "number",
                  "desc": "The port which the socket is attempting to connect to."
                },
                {
                  "textRaw": "`family` {number} The family of the IP. It can be `6` for IPv6 or `4` for IPv4.",
                  "name": "family",
                  "type": "number",
                  "desc": "The family of the IP. It can be `6` for IPv6 or `4` for IPv4."
                }
              ],
              "desc": "<p>Emitted when a new connection attempt is started. This may be emitted multiple times\nif the family autoselection algorithm is enabled in <a href=\"#socketconnectoptions-connectlistener\"><code>socket.connect(options)</code></a>.</p>"
            },
            {
              "textRaw": "Event: `'connectionAttemptFailed'`",
              "name": "connectionAttemptFailed",
              "type": "event",
              "meta": {
                "added": [
                  "v21.6.0",
                  "v20.12.0"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`ip` {string} The IP which the socket attempted to connect to.",
                  "name": "ip",
                  "type": "string",
                  "desc": "The IP which the socket attempted to connect to."
                },
                {
                  "textRaw": "`port` {number} The port which the socket attempted to connect to.",
                  "name": "port",
                  "type": "number",
                  "desc": "The port which the socket attempted to connect to."
                },
                {
                  "textRaw": "`family` {number} The family of the IP. It can be `6` for IPv6 or `4` for IPv4.",
                  "name": "family",
                  "type": "number",
                  "desc": "The family of the IP. It can be `6` for IPv6 or `4` for IPv4."
                },
                {
                  "textRaw": "`error` {Error} The error associated with the failure.",
                  "name": "error",
                  "type": "Error",
                  "desc": "The error associated with the failure."
                }
              ],
              "desc": "<p>Emitted when a connection attempt failed. This may be emitted multiple times\nif the family autoselection algorithm is enabled in <a href=\"#socketconnectoptions-connectlistener\"><code>socket.connect(options)</code></a>.</p>"
            },
            {
              "textRaw": "Event: `'connectionAttemptTimeout'`",
              "name": "connectionAttemptTimeout",
              "type": "event",
              "meta": {
                "added": [
                  "v21.6.0",
                  "v20.12.0"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`ip` {string} The IP which the socket attempted to connect to.",
                  "name": "ip",
                  "type": "string",
                  "desc": "The IP which the socket attempted to connect to."
                },
                {
                  "textRaw": "`port` {number} The port which the socket attempted to connect to.",
                  "name": "port",
                  "type": "number",
                  "desc": "The port which the socket attempted to connect to."
                },
                {
                  "textRaw": "`family` {number} The family of the IP. It can be `6` for IPv6 or `4` for IPv4.",
                  "name": "family",
                  "type": "number",
                  "desc": "The family of the IP. It can be `6` for IPv6 or `4` for IPv4."
                }
              ],
              "desc": "<p>Emitted when a connection attempt timed out. This is only emitted (and may be\nemitted multiple times) if the family autoselection algorithm is enabled\nin <a href=\"#socketconnectoptions-connectlistener\"><code>socket.connect(options)</code></a>.</p>"
            },
            {
              "textRaw": "Event: `'data'`",
              "name": "data",
              "type": "event",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "Type: {Buffer|string}",
                  "name": "type",
                  "type": "Buffer|string"
                }
              ],
              "desc": "<p>Emitted when data is received. The argument <code>data</code> will be a <code>Buffer</code> or\n<code>String</code>. Encoding of data is set by <a href=\"#socketsetencodingencoding\"><code>socket.setEncoding()</code></a>.</p>\n<p>The data will be lost if there is no listener when a <code>Socket</code>\nemits a <code>'data'</code> event.</p>"
            },
            {
              "textRaw": "Event: `'drain'`",
              "name": "drain",
              "type": "event",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "params": [],
              "desc": "<p>Emitted when the write buffer becomes empty. Can be used to throttle uploads.</p>\n<p>See also: the return values of <code>socket.write()</code>.</p>"
            },
            {
              "textRaw": "Event: `'end'`",
              "name": "end",
              "type": "event",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "params": [],
              "desc": "<p>Emitted when the other end of the socket signals the end of transmission, thus\nending the readable side of the socket.</p>\n<p>By default (<code>allowHalfOpen</code> is <code>false</code>) the socket will send an end of\ntransmission packet back and destroy its file descriptor once it has written out\nits pending write queue. However, if <code>allowHalfOpen</code> is set to <code>true</code>, the\nsocket will not automatically <a href=\"#socketenddata-encoding-callback\"><code>end()</code></a> its writable side,\nallowing the user to write arbitrary amounts of data. The user must call\n<a href=\"#socketenddata-encoding-callback\"><code>end()</code></a> explicitly to close the connection (i.e. sending a\nFIN packet back).</p>"
            },
            {
              "textRaw": "Event: `'error'`",
              "name": "error",
              "type": "event",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "Type: {Error}",
                  "name": "type",
                  "type": "Error"
                }
              ],
              "desc": "<p>Emitted when an error occurs. The <code>'close'</code> event will be called directly\nfollowing this event.</p>"
            },
            {
              "textRaw": "Event: `'lookup'`",
              "name": "lookup",
              "type": "event",
              "meta": {
                "added": [
                  "v0.11.3"
                ],
                "changes": [
                  {
                    "version": "v5.10.0",
                    "pr-url": "https://github.com/nodejs/node/pull/5598",
                    "description": "The `host` parameter is supported now."
                  }
                ]
              },
              "params": [
                {
                  "textRaw": "`err` {Error|null} The error object. See `dns.lookup()`.",
                  "name": "err",
                  "type": "Error|null",
                  "desc": "The error object. See `dns.lookup()`."
                },
                {
                  "textRaw": "`address` {string} The IP address.",
                  "name": "address",
                  "type": "string",
                  "desc": "The IP address."
                },
                {
                  "textRaw": "`family` {number|null} The address type. See `dns.lookup()`.",
                  "name": "family",
                  "type": "number|null",
                  "desc": "The address type. See `dns.lookup()`."
                },
                {
                  "textRaw": "`host` {string} The host name.",
                  "name": "host",
                  "type": "string",
                  "desc": "The host name."
                }
              ],
              "desc": "<p>Emitted after resolving the host name but before connecting.\nNot applicable to Unix sockets.</p>"
            },
            {
              "textRaw": "Event: `'ready'`",
              "name": "ready",
              "type": "event",
              "meta": {
                "added": [
                  "v9.11.0"
                ],
                "changes": []
              },
              "params": [],
              "desc": "<p>Emitted when a socket is ready to be used.</p>\n<p>Triggered immediately after <code>'connect'</code>.</p>"
            },
            {
              "textRaw": "Event: `'timeout'`",
              "name": "timeout",
              "type": "event",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "params": [],
              "desc": "<p>Emitted if the socket times out from inactivity. This is only to notify that\nthe socket has been idle. The user must manually close the connection.</p>\n<p>See also: <a href=\"#socketsettimeouttimeout-callback\"><code>socket.setTimeout()</code></a>.</p>"
            }
          ],
          "methods": [
            {
              "textRaw": "`socket.address()`",
              "name": "address",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": [
                  {
                    "version": "v18.4.0",
                    "pr-url": "https://github.com/nodejs/node/pull/43054",
                    "description": "The `family` property now returns a string instead of a number."
                  },
                  {
                    "version": "v18.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/41431",
                    "description": "The `family` property now returns a number instead of a string."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {Object}",
                    "name": "return",
                    "type": "Object"
                  }
                }
              ],
              "desc": "<p>Returns the bound <code>address</code>, the address <code>family</code> name and <code>port</code> of the\nsocket as reported by the operating system:\n<code>{ port: 12346, family: 'IPv4', address: '127.0.0.1' }</code></p>"
            },
            {
              "textRaw": "`socket.connect()`",
              "name": "connect",
              "type": "method",
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Initiate a connection on a given socket.</p>\n<p>Possible signatures:</p>\n<ul>\n<li><a href=\"#socketconnectoptions-connectlistener\"><code>socket.connect(options[, connectListener])</code></a></li>\n<li><a href=\"#socketconnectpath-connectlistener\"><code>socket.connect(path[, connectListener])</code></a>\nfor <a href=\"#ipc-support\">IPC</a> connections.</li>\n<li><a href=\"#socketconnectport-host-connectlistener\"><code>socket.connect(port[, host][, connectListener])</code></a>\nfor TCP connections.</li>\n<li>Returns: <a href=\"net.html#class-netsocket\"><code>&#x3C;net.Socket></code></a> The socket itself.</li>\n</ul>\n<p>This function is asynchronous. When the connection is established, the\n<a href=\"#event-connect\"><code>'connect'</code></a> event will be emitted. If there is a problem connecting,\ninstead of a <a href=\"#event-connect\"><code>'connect'</code></a> event, an <a href=\"#event-error_1\"><code>'error'</code></a> event will be emitted with\nthe error passed to the <a href=\"#event-error_1\"><code>'error'</code></a> listener.\nThe last parameter <code>connectListener</code>, if supplied, will be added as a listener\nfor the <a href=\"#event-connect\"><code>'connect'</code></a> event <strong>once</strong>.</p>\n<p>This function should only be used for reconnecting a socket after\n<code>'close'</code> has been emitted or otherwise it may lead to undefined\nbehavior.</p>",
              "methods": [
                {
                  "textRaw": "`socket.connect(options[, connectListener])`",
                  "name": "connect",
                  "type": "method",
                  "meta": {
                    "added": [
                      "v0.1.90"
                    ],
                    "changes": [
                      {
                        "version": [
                          "v20.0.0",
                          "v18.18.0"
                        ],
                        "pr-url": "https://github.com/nodejs/node/pull/46790",
                        "description": "The default value for the autoSelectFamily option is now true. The `--enable-network-family-autoselection` CLI flag has been renamed to `--network-family-autoselection`. The old name is now an alias but it is discouraged."
                      },
                      {
                        "version": "v19.4.0",
                        "pr-url": "https://github.com/nodejs/node/pull/45777",
                        "description": "The default value for autoSelectFamily option can be changed at runtime using `setDefaultAutoSelectFamily` or via the command line option `--enable-network-family-autoselection`."
                      },
                      {
                        "version": [
                          "v19.3.0",
                          "v18.13.0"
                        ],
                        "pr-url": "https://github.com/nodejs/node/pull/44731",
                        "description": "Added the `autoSelectFamily` option."
                      },
                      {
                        "version": [
                          "v17.7.0",
                          "v16.15.0"
                        ],
                        "pr-url": "https://github.com/nodejs/node/pull/41310",
                        "description": "The `noDelay`, `keepAlive`, and `keepAliveInitialDelay` options are supported now."
                      },
                      {
                        "version": "v6.0.0",
                        "pr-url": "https://github.com/nodejs/node/pull/6021",
                        "description": "The `hints` option defaults to `0` in all cases now. Previously, in the absence of the `family` option it would default to `dns.ADDRCONFIG | dns.V4MAPPED`."
                      },
                      {
                        "version": "v5.11.0",
                        "pr-url": "https://github.com/nodejs/node/pull/6000",
                        "description": "The `hints` option is supported now."
                      }
                    ]
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`options` {Object}",
                          "name": "options",
                          "type": "Object"
                        },
                        {
                          "textRaw": "`connectListener` {Function} Common parameter of `socket.connect()` methods. Will be added as a listener for the `'connect'` event once.",
                          "name": "connectListener",
                          "type": "Function",
                          "desc": "Common parameter of `socket.connect()` methods. Will be added as a listener for the `'connect'` event once.",
                          "optional": true
                        }
                      ],
                      "return": {
                        "textRaw": "Returns: {net.Socket} The socket itself.",
                        "name": "return",
                        "type": "net.Socket",
                        "desc": "The socket itself."
                      }
                    }
                  ],
                  "desc": "<p>Initiate a connection on a given socket. Normally this method is not needed,\nthe socket should be created and opened with <a href=\"#netcreateconnection\"><code>net.createConnection()</code></a>. Use\nthis only when implementing a custom Socket.</p>\n<p>For TCP connections, available <code>options</code> are:</p>\n<ul>\n<li><code>autoSelectFamily</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type\"><code>&#x3C;boolean></code></a>: If set to <code>true</code>, it enables a family\nautodetection algorithm that loosely implements section 5 of <a href=\"https://www.rfc-editor.org/rfc/rfc8305.txt\">RFC 8305</a>. The\n<code>all</code> option passed to lookup is set to <code>true</code> and the sockets attempts to\nconnect to all obtained IPv6 and IPv4 addresses, in sequence, until a\nconnection is established. The first returned AAAA address is tried first,\nthen the first returned A address, then the second returned AAAA address and\nso on. Each connection attempt (but the last one) is given the amount of time\nspecified by the <code>autoSelectFamilyAttemptTimeout</code> option before timing out and\ntrying the next address. Ignored if the <code>family</code> option is not <code>0</code> or if\n<code>localAddress</code> is set. Connection errors are not emitted if at least one\nconnection succeeds. If all connections attempts fails, a single\n<code>AggregateError</code> with all failed attempts is emitted. <strong>Default:</strong>\n<a href=\"#netgetdefaultautoselectfamily\"><code>net.getDefaultAutoSelectFamily()</code></a>.</li>\n<li><code>autoSelectFamilyAttemptTimeout</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a>: The amount of time in milliseconds\nto wait for a connection attempt to finish before trying the next address when\nusing the <code>autoSelectFamily</code> option. If set to a positive integer less than\n<code>10</code>, then the value <code>10</code> will be used instead. <strong>Default:</strong>\n<a href=\"#netgetdefaultautoselectfamilyattempttimeout\"><code>net.getDefaultAutoSelectFamilyAttemptTimeout()</code></a>.</li>\n<li><code>family</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a>: Version of IP stack. Must be <code>4</code>, <code>6</code>, or <code>0</code>. The value\n<code>0</code> indicates that both IPv4 and IPv6 addresses are allowed. <strong>Default:</strong> <code>0</code>.</li>\n<li><code>hints</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a> Optional <a href=\"dns.html#supported-getaddrinfo-flags\"><code>dns.lookup()</code> hints</a>.</li>\n<li><code>host</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> Host the socket should connect to. <strong>Default:</strong> <code>'localhost'</code>.</li>\n<li><code>localAddress</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> Local address the socket should connect from.</li>\n<li><code>localPort</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a> Local port the socket should connect from.</li>\n<li><code>lookup</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\"><code>&#x3C;Function></code></a> Custom lookup function. <strong>Default:</strong> <a href=\"dns.html#dnslookuphostname-options-callback\"><code>dns.lookup()</code></a>.</li>\n<li><code>port</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a> Required. Port the socket should connect to.</li>\n</ul>\n<p>For <a href=\"#ipc-support\">IPC</a> connections, available <code>options</code> are:</p>\n<ul>\n<li><code>path</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> Required. Path the client should connect to.\nSee <a href=\"#identifying-paths-for-ipc-connections\">Identifying paths for IPC connections</a>. If provided, the TCP-specific\noptions above are ignored.</li>\n</ul>"
                },
                {
                  "textRaw": "`socket.connect(path[, connectListener])`",
                  "name": "connect",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`path` {string} Path the client should connect to. See Identifying paths for IPC connections.",
                          "name": "path",
                          "type": "string",
                          "desc": "Path the client should connect to. See Identifying paths for IPC connections."
                        },
                        {
                          "textRaw": "`connectListener` {Function} Common parameter of `socket.connect()` methods. Will be added as a listener for the `'connect'` event once.",
                          "name": "connectListener",
                          "type": "Function",
                          "desc": "Common parameter of `socket.connect()` methods. Will be added as a listener for the `'connect'` event once.",
                          "optional": true
                        }
                      ],
                      "return": {
                        "textRaw": "Returns: {net.Socket} The socket itself.",
                        "name": "return",
                        "type": "net.Socket",
                        "desc": "The socket itself."
                      }
                    }
                  ],
                  "desc": "<p>Initiate an <a href=\"#ipc-support\">IPC</a> connection on the given socket.</p>\n<p>Alias to\n<a href=\"#socketconnectoptions-connectlistener\"><code>socket.connect(options[, connectListener])</code></a>\ncalled with <code>{ path: path }</code> as <code>options</code>.</p>"
                },
                {
                  "textRaw": "`socket.connect(port[, host][, connectListener])`",
                  "name": "connect",
                  "type": "method",
                  "meta": {
                    "added": [
                      "v0.1.90"
                    ],
                    "changes": []
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`port` {number} Port the client should connect to.",
                          "name": "port",
                          "type": "number",
                          "desc": "Port the client should connect to."
                        },
                        {
                          "textRaw": "`host` {string} Host the client should connect to.",
                          "name": "host",
                          "type": "string",
                          "desc": "Host the client should connect to.",
                          "optional": true
                        },
                        {
                          "textRaw": "`connectListener` {Function} Common parameter of `socket.connect()` methods. Will be added as a listener for the `'connect'` event once.",
                          "name": "connectListener",
                          "type": "Function",
                          "desc": "Common parameter of `socket.connect()` methods. Will be added as a listener for the `'connect'` event once.",
                          "optional": true
                        }
                      ],
                      "return": {
                        "textRaw": "Returns: {net.Socket} The socket itself.",
                        "name": "return",
                        "type": "net.Socket",
                        "desc": "The socket itself."
                      }
                    }
                  ],
                  "desc": "<p>Initiate a TCP connection on the given socket.</p>\n<p>Alias to\n<a href=\"#socketconnectoptions-connectlistener\"><code>socket.connect(options[, connectListener])</code></a>\ncalled with <code>{port: port, host: host}</code> as <code>options</code>.</p>"
                }
              ]
            },
            {
              "textRaw": "`socket.destroy([error])`",
              "name": "destroy",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`error` {Object}",
                      "name": "error",
                      "type": "Object",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {net.Socket}",
                    "name": "return",
                    "type": "net.Socket"
                  }
                }
              ],
              "desc": "<p>Ensures that no more I/O activity happens on this socket.\nDestroys the stream and closes the connection.</p>\n<p>See <a href=\"stream.html#writabledestroyerror\"><code>writable.destroy()</code></a> for further details.</p>"
            },
            {
              "textRaw": "`socket.destroySoon()`",
              "name": "destroySoon",
              "type": "method",
              "meta": {
                "added": [
                  "v0.3.4"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Destroys the socket after all data is written. If the <code>'finish'</code> event was\nalready emitted the socket is destroyed immediately. If the socket is still\nwritable it implicitly calls <code>socket.end()</code>.</p>"
            },
            {
              "textRaw": "`socket.end([data[, encoding]][, callback])`",
              "name": "end",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`data` {string|Buffer|Uint8Array}",
                      "name": "data",
                      "type": "string|Buffer|Uint8Array",
                      "optional": true
                    },
                    {
                      "textRaw": "`encoding` {string} Only used when data is `string`. **Default:** `'utf8'`.",
                      "name": "encoding",
                      "type": "string",
                      "default": "`'utf8'`",
                      "desc": "Only used when data is `string`.",
                      "optional": true
                    },
                    {
                      "textRaw": "`callback` {Function} Optional callback for when the socket is finished.",
                      "name": "callback",
                      "type": "Function",
                      "desc": "Optional callback for when the socket is finished.",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {net.Socket} The socket itself.",
                    "name": "return",
                    "type": "net.Socket",
                    "desc": "The socket itself."
                  }
                }
              ],
              "desc": "<p>Half-closes the socket. i.e., it sends a FIN packet. It is possible the\nserver will still send some data.</p>\n<p>See <a href=\"stream.html#writableendchunk-encoding-callback\"><code>writable.end()</code></a> for further details.</p>"
            },
            {
              "textRaw": "`socket.pause()`",
              "name": "pause",
              "type": "method",
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {net.Socket} The socket itself.",
                    "name": "return",
                    "type": "net.Socket",
                    "desc": "The socket itself."
                  }
                }
              ],
              "desc": "<p>Pauses the reading of data. That is, <a href=\"#event-data\"><code>'data'</code></a> events will not be emitted.\nUseful to throttle back an upload.</p>"
            },
            {
              "textRaw": "`socket.ref()`",
              "name": "ref",
              "type": "method",
              "meta": {
                "added": [
                  "v0.9.1"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {net.Socket} The socket itself.",
                    "name": "return",
                    "type": "net.Socket",
                    "desc": "The socket itself."
                  }
                }
              ],
              "desc": "<p>Opposite of <code>unref()</code>, calling <code>ref()</code> on a previously <code>unref</code>ed socket will\n<em>not</em> let the program exit if it's the only socket left (the default behavior).\nIf the socket is <code>ref</code>ed calling <code>ref</code> again will have no effect.</p>"
            },
            {
              "textRaw": "`socket.resetAndDestroy()`",
              "name": "resetAndDestroy",
              "type": "method",
              "meta": {
                "added": [
                  "v18.3.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {net.Socket}",
                    "name": "return",
                    "type": "net.Socket"
                  }
                }
              ],
              "desc": "<p>Close the TCP connection by sending an RST packet and destroy the stream.\nIf this TCP socket is in connecting status, it will send an RST packet and destroy this TCP socket once it is connected.\nOtherwise, it will call <code>socket.destroy</code> with an <code>ERR_SOCKET_CLOSED</code> Error.\nIf this is not a TCP socket (for example, a pipe), calling this method will immediately throw an <code>ERR_INVALID_HANDLE_TYPE</code> Error.</p>"
            },
            {
              "textRaw": "`socket.resume()`",
              "name": "resume",
              "type": "method",
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {net.Socket} The socket itself.",
                    "name": "return",
                    "type": "net.Socket",
                    "desc": "The socket itself."
                  }
                }
              ],
              "desc": "<p>Resumes reading after a call to <a href=\"#socketpause\"><code>socket.pause()</code></a>.</p>"
            },
            {
              "textRaw": "`socket.setEncoding([encoding])`",
              "name": "setEncoding",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`encoding` {string}",
                      "name": "encoding",
                      "type": "string",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {net.Socket} The socket itself.",
                    "name": "return",
                    "type": "net.Socket",
                    "desc": "The socket itself."
                  }
                }
              ],
              "desc": "<p>Set the encoding for the socket as a <a href=\"stream.html#class-streamreadable\">Readable Stream</a>. See\n<a href=\"stream.html#readablesetencodingencoding\"><code>readable.setEncoding()</code></a> for more information.</p>"
            },
            {
              "textRaw": "`socket.setKeepAlive([enable][, initialDelay])`",
              "name": "setKeepAlive",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.92"
                ],
                "changes": [
                  {
                    "version": [
                      "v13.12.0",
                      "v12.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/32204",
                    "description": "New defaults for `TCP_KEEPCNT` and `TCP_KEEPINTVL` socket options were added."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`enable` {boolean} **Default:** `false`",
                      "name": "enable",
                      "type": "boolean",
                      "default": "`false`",
                      "optional": true
                    },
                    {
                      "textRaw": "`initialDelay` {number} **Default:** `0`",
                      "name": "initialDelay",
                      "type": "number",
                      "default": "`0`",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {net.Socket} The socket itself.",
                    "name": "return",
                    "type": "net.Socket",
                    "desc": "The socket itself."
                  }
                }
              ],
              "desc": "<p>Enable/disable keep-alive functionality, and optionally set the initial\ndelay before the first keepalive probe is sent on an idle socket.</p>\n<p>Set <code>initialDelay</code> (in milliseconds) to set the delay between the last\ndata packet received and the first keepalive probe. Setting <code>0</code> for\n<code>initialDelay</code> will leave the value unchanged from the default\n(or previous) setting.</p>\n<p>Enabling the keep-alive functionality will set the following socket options:</p>\n<ul>\n<li><code>SO_KEEPALIVE=1</code></li>\n<li><code>TCP_KEEPIDLE=initialDelay</code></li>\n<li><code>TCP_KEEPCNT=10</code></li>\n<li><code>TCP_KEEPINTVL=1</code></li>\n</ul>"
            },
            {
              "textRaw": "`socket.setNoDelay([noDelay])`",
              "name": "setNoDelay",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`noDelay` {boolean} **Default:** `true`",
                      "name": "noDelay",
                      "type": "boolean",
                      "default": "`true`",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {net.Socket} The socket itself.",
                    "name": "return",
                    "type": "net.Socket",
                    "desc": "The socket itself."
                  }
                }
              ],
              "desc": "<p>Enable/disable the use of Nagle's algorithm.</p>\n<p>When a TCP connection is created, it will have Nagle's algorithm enabled.</p>\n<p>Nagle's algorithm delays data before it is sent via the network. It attempts\nto optimize throughput at the expense of latency.</p>\n<p>Passing <code>true</code> for <code>noDelay</code> or not passing an argument will disable Nagle's\nalgorithm for the socket. Passing <code>false</code> for <code>noDelay</code> will enable Nagle's\nalgorithm.</p>"
            },
            {
              "textRaw": "`socket.setTimeout(timeout[, callback])`",
              "name": "setTimeout",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": [
                  {
                    "version": "v18.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/41678",
                    "description": "Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`timeout` {number}",
                      "name": "timeout",
                      "type": "number"
                    },
                    {
                      "textRaw": "`callback` {Function}",
                      "name": "callback",
                      "type": "Function",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {net.Socket} The socket itself.",
                    "name": "return",
                    "type": "net.Socket",
                    "desc": "The socket itself."
                  }
                }
              ],
              "desc": "<p>Sets the socket to timeout after <code>timeout</code> milliseconds of inactivity on\nthe socket. By default <code>net.Socket</code> do not have a timeout.</p>\n<p>When an idle timeout is triggered the socket will receive a <a href=\"#event-timeout\"><code>'timeout'</code></a>\nevent but the connection will not be severed. The user must manually call\n<a href=\"#socketenddata-encoding-callback\"><code>socket.end()</code></a> or <a href=\"#socketdestroyerror\"><code>socket.destroy()</code></a> to end the connection.</p>\n<pre><code class=\"language-js\">socket.setTimeout(3000);\nsocket.on('timeout', () => {\n  console.log('socket timeout');\n  socket.end();\n});\n</code></pre>\n<p>If <code>timeout</code> is 0, then the existing idle timeout is disabled.</p>\n<p>The optional <code>callback</code> parameter will be added as a one-time listener for the\n<a href=\"#event-timeout\"><code>'timeout'</code></a> event.</p>"
            },
            {
              "textRaw": "`socket.getTypeOfService()`",
              "name": "getTypeOfService",
              "type": "method",
              "meta": {
                "added": [
                  "v25.6.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {integer} The current TOS value.",
                    "name": "return",
                    "type": "integer",
                    "desc": "The current TOS value."
                  }
                }
              ],
              "desc": "<p>Returns the current Type of Service (TOS) field for IPv4 packets or Traffic\nClass for IPv6 packets for this socket.</p>\n<p><code>setTypeOfService()</code> may be called before the socket is connected; the value\nwill be cached and applied when the socket establishes a connection.\n<code>getTypeOfService()</code> will return the currently set value even before connection.</p>\n<p>On some platforms (e.g., Linux), certain TOS/ECN bits may be masked or ignored,\nand behavior can differ between IPv4 and IPv6 or dual-stack sockets. Callers\nshould verify platform-specific semantics.</p>"
            },
            {
              "textRaw": "`socket.setTypeOfService(tos)`",
              "name": "setTypeOfService",
              "type": "method",
              "meta": {
                "added": [
                  "v25.6.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`tos` {integer} The TOS value to set (0-255).",
                      "name": "tos",
                      "type": "integer",
                      "desc": "The TOS value to set (0-255)."
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {net.Socket} The socket itself.",
                    "name": "return",
                    "type": "net.Socket",
                    "desc": "The socket itself."
                  }
                }
              ],
              "desc": "<p>Sets the Type of Service (TOS) field for IPv4 packets or Traffic Class for IPv6\nPackets sent from this socket. This can be used to prioritize network traffic.</p>\n<p><code>setTypeOfService()</code> may be called before the socket is connected; the value\nwill be cached and applied when the socket establishes a connection.\n<code>getTypeOfService()</code> will return the currently set value even before connection.</p>\n<p>On some platforms (e.g., Linux), certain TOS/ECN bits may be masked or ignored,\nand behavior can differ between IPv4 and IPv6 or dual-stack sockets. Callers\nshould verify platform-specific semantics.</p>"
            },
            {
              "textRaw": "`socket.unref()`",
              "name": "unref",
              "type": "method",
              "meta": {
                "added": [
                  "v0.9.1"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {net.Socket} The socket itself.",
                    "name": "return",
                    "type": "net.Socket",
                    "desc": "The socket itself."
                  }
                }
              ],
              "desc": "<p>Calling <code>unref()</code> on a socket will allow the program to exit if this is the only\nactive socket in the event system. If the socket is already <code>unref</code>ed calling\n<code>unref()</code> again will have no effect.</p>"
            },
            {
              "textRaw": "`socket.write(data[, encoding][, callback])`",
              "name": "write",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`data` {string|Buffer|Uint8Array}",
                      "name": "data",
                      "type": "string|Buffer|Uint8Array"
                    },
                    {
                      "textRaw": "`encoding` {string} Only used when data is `string`. **Default:** `utf8`.",
                      "name": "encoding",
                      "type": "string",
                      "default": "`utf8`",
                      "desc": "Only used when data is `string`.",
                      "optional": true
                    },
                    {
                      "textRaw": "`callback` {Function}",
                      "name": "callback",
                      "type": "Function",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {boolean}",
                    "name": "return",
                    "type": "boolean"
                  }
                }
              ],
              "desc": "<p>Sends data on the socket. The second parameter specifies the encoding in the\ncase of a string. It defaults to UTF8 encoding.</p>\n<p>Returns <code>true</code> if the entire data was flushed successfully to the kernel\nbuffer. Returns <code>false</code> if all or part of the data was queued in user memory.\n<a href=\"#event-drain\"><code>'drain'</code></a> will be emitted when the buffer is again free.</p>\n<p>The optional <code>callback</code> parameter will be executed when the data is finally\nwritten out, which may not be immediately.</p>\n<p>See <code>Writable</code> stream <a href=\"stream.html#writablewritechunk-encoding-callback\"><code>write()</code></a> method for more\ninformation.</p>"
            }
          ],
          "properties": [
            {
              "textRaw": "Type: {string[]}",
              "name": "autoSelectFamilyAttemptedAddresses",
              "type": "string[]",
              "meta": {
                "added": [
                  "v19.4.0",
                  "v18.18.0"
                ],
                "changes": []
              },
              "desc": "<p>This property is only present if the family autoselection algorithm is enabled in\n<a href=\"#socketconnectoptions-connectlistener\"><code>socket.connect(options)</code></a> and it is an array of the addresses that have been attempted.</p>\n<p>Each address is a string in the form of <code>$IP:$PORT</code>. If the connection was successful,\nthen the last address is the one that the socket is currently connected to.</p>"
            },
            {
              "textRaw": "Type: {integer}",
              "name": "bufferSize",
              "type": "integer",
              "meta": {
                "added": [
                  "v0.3.8"
                ],
                "changes": [],
                "deprecated": [
                  "v14.6.0"
                ]
              },
              "stability": 0,
              "stabilityText": "Deprecated: Use `writable.writableLength` instead.",
              "desc": "<p>This property shows the number of characters buffered for writing. The buffer\nmay contain strings whose length after encoding is not yet known. So this number\nis only an approximation of the number of bytes in the buffer.</p>\n<p><code>net.Socket</code> has the property that <code>socket.write()</code> always works. This is to\nhelp users get up and running quickly. The computer cannot always keep up\nwith the amount of data that is written to a socket. The network connection\nsimply might be too slow. Node.js will internally queue up the data written to a\nsocket and send it out over the wire when it is possible.</p>\n<p>The consequence of this internal buffering is that memory may grow.\nUsers who experience large or growing <code>bufferSize</code> should attempt to\n\"throttle\" the data flows in their program with\n<a href=\"#socketpause\"><code>socket.pause()</code></a> and <a href=\"#socketresume\"><code>socket.resume()</code></a>.</p>"
            },
            {
              "textRaw": "Type: {integer}",
              "name": "bytesRead",
              "type": "integer",
              "meta": {
                "added": [
                  "v0.5.3"
                ],
                "changes": []
              },
              "desc": "<p>The amount of received bytes.</p>"
            },
            {
              "textRaw": "Type: {integer}",
              "name": "bytesWritten",
              "type": "integer",
              "meta": {
                "added": [
                  "v0.5.3"
                ],
                "changes": []
              },
              "desc": "<p>The amount of bytes sent.</p>"
            },
            {
              "textRaw": "Type: {boolean}",
              "name": "connecting",
              "type": "boolean",
              "meta": {
                "added": [
                  "v6.1.0"
                ],
                "changes": []
              },
              "desc": "<p>If <code>true</code>,\n<a href=\"#socketconnectoptions-connectlistener\"><code>socket.connect(options[, connectListener])</code></a> was\ncalled and has not yet finished. It will stay <code>true</code> until the socket becomes\nconnected, then it is set to <code>false</code> and the <code>'connect'</code> event is emitted. Note\nthat the\n<a href=\"#socketconnectoptions-connectlistener\"><code>socket.connect(options[, connectListener])</code></a>\ncallback is a listener for the <code>'connect'</code> event.</p>"
            },
            {
              "textRaw": "Type: {boolean} Indicates if the connection is destroyed or not. Once a connection is destroyed no further data can be transferred using it.",
              "name": "destroyed",
              "type": "boolean",
              "desc": "<p>See <a href=\"stream.html#writabledestroyed\"><code>writable.destroyed</code></a> for further details.</p>",
              "shortDesc": "Indicates if the connection is destroyed or not. Once a connection is destroyed no further data can be transferred using it."
            },
            {
              "textRaw": "Type: {string}",
              "name": "localAddress",
              "type": "string",
              "meta": {
                "added": [
                  "v0.9.6"
                ],
                "changes": []
              },
              "desc": "<p>The string representation of the local IP address the remote client is\nconnecting on. For example, in a server listening on <code>'0.0.0.0'</code>, if a client\nconnects on <code>'192.168.1.1'</code>, the value of <code>socket.localAddress</code> would be\n<code>'192.168.1.1'</code>.</p>"
            },
            {
              "textRaw": "Type: {integer}",
              "name": "localPort",
              "type": "integer",
              "meta": {
                "added": [
                  "v0.9.6"
                ],
                "changes": []
              },
              "desc": "<p>The numeric representation of the local port. For example, <code>80</code> or <code>21</code>.</p>"
            },
            {
              "textRaw": "Type: {string}",
              "name": "localFamily",
              "type": "string",
              "meta": {
                "added": [
                  "v18.8.0",
                  "v16.18.0"
                ],
                "changes": []
              },
              "desc": "<p>The string representation of the local IP family. <code>'IPv4'</code> or <code>'IPv6'</code>.</p>"
            },
            {
              "textRaw": "Type: {boolean}",
              "name": "pending",
              "type": "boolean",
              "meta": {
                "added": [
                  "v11.2.0",
                  "v10.16.0"
                ],
                "changes": []
              },
              "desc": "<p>This is <code>true</code> if the socket is not connected yet, either because <code>.connect()</code>\nhas not yet been called or because it is still in the process of connecting\n(see <a href=\"#socketconnecting\"><code>socket.connecting</code></a>).</p>"
            },
            {
              "textRaw": "Type: {string}",
              "name": "remoteAddress",
              "type": "string",
              "meta": {
                "added": [
                  "v0.5.10"
                ],
                "changes": []
              },
              "desc": "<p>The string representation of the remote IP address. For example,\n<code>'74.125.127.100'</code> or <code>'2001:4860:a005::68'</code>. Value may be <code>undefined</code> if\nthe socket is destroyed (for example, if the client disconnected).</p>"
            },
            {
              "textRaw": "Type: {string}",
              "name": "remoteFamily",
              "type": "string",
              "meta": {
                "added": [
                  "v0.11.14"
                ],
                "changes": []
              },
              "desc": "<p>The string representation of the remote IP family. <code>'IPv4'</code> or <code>'IPv6'</code>. Value may be <code>undefined</code> if\nthe socket is destroyed (for example, if the client disconnected).</p>"
            },
            {
              "textRaw": "Type: {integer}",
              "name": "remotePort",
              "type": "integer",
              "meta": {
                "added": [
                  "v0.5.10"
                ],
                "changes": []
              },
              "desc": "<p>The numeric representation of the remote port. For example, <code>80</code> or <code>21</code>. Value may be <code>undefined</code> if\nthe socket is destroyed (for example, if the client disconnected).</p>"
            },
            {
              "textRaw": "Type: {number|undefined}",
              "name": "timeout",
              "type": "number|undefined",
              "meta": {
                "added": [
                  "v10.7.0"
                ],
                "changes": []
              },
              "desc": "<p>The socket timeout in milliseconds as set by <a href=\"#socketsettimeouttimeout-callback\"><code>socket.setTimeout()</code></a>.\nIt is <code>undefined</code> if a timeout has not been set.</p>"
            },
            {
              "textRaw": "Type: {string}",
              "name": "readyState",
              "type": "string",
              "meta": {
                "added": [
                  "v0.5.0"
                ],
                "changes": []
              },
              "desc": "<p>This property represents the state of the connection as a string.</p>\n<ul>\n<li>If the stream is connecting <code>socket.readyState</code> is <code>opening</code>.</li>\n<li>If the stream is readable and writable, it is <code>open</code>.</li>\n<li>If the stream is readable and not writable, it is <code>readOnly</code>.</li>\n<li>If the stream is not readable and writable, it is <code>writeOnly</code>.</li>\n</ul>"
            }
          ]
        }
      ],
      "methods": [
        {
          "textRaw": "`net.connect()`",
          "name": "connect",
          "type": "method",
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Aliases to\n<a href=\"#netcreateconnection\"><code>net.createConnection()</code></a>.</p>\n<p>Possible signatures:</p>\n<ul>\n<li><a href=\"#netconnectoptions-connectlistener\"><code>net.connect(options[, connectListener])</code></a></li>\n<li><a href=\"#netconnectpath-connectlistener\"><code>net.connect(path[, connectListener])</code></a> for <a href=\"#ipc-support\">IPC</a>\nconnections.</li>\n<li><a href=\"#netconnectport-host-connectlistener\"><code>net.connect(port[, host][, connectListener])</code></a>\nfor TCP connections.</li>\n</ul>",
          "methods": [
            {
              "textRaw": "`net.connect(options[, connectListener])`",
              "name": "connect",
              "type": "method",
              "meta": {
                "added": [
                  "v0.7.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object"
                    },
                    {
                      "textRaw": "`connectListener` {Function}",
                      "name": "connectListener",
                      "type": "Function",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {net.Socket}",
                    "name": "return",
                    "type": "net.Socket"
                  }
                }
              ],
              "desc": "<p>Alias to\n<a href=\"#netcreateconnectionoptions-connectlistener\"><code>net.createConnection(options[, connectListener])</code></a>.</p>"
            },
            {
              "textRaw": "`net.connect(path[, connectListener])`",
              "name": "connect",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`path` {string}",
                      "name": "path",
                      "type": "string"
                    },
                    {
                      "textRaw": "`connectListener` {Function}",
                      "name": "connectListener",
                      "type": "Function",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {net.Socket}",
                    "name": "return",
                    "type": "net.Socket"
                  }
                }
              ],
              "desc": "<p>Alias to\n<a href=\"#netcreateconnectionpath-connectlistener\"><code>net.createConnection(path[, connectListener])</code></a>.</p>"
            },
            {
              "textRaw": "`net.connect(port[, host][, connectListener])`",
              "name": "connect",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`port` {number}",
                      "name": "port",
                      "type": "number"
                    },
                    {
                      "textRaw": "`host` {string}",
                      "name": "host",
                      "type": "string",
                      "optional": true
                    },
                    {
                      "textRaw": "`connectListener` {Function}",
                      "name": "connectListener",
                      "type": "Function",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {net.Socket}",
                    "name": "return",
                    "type": "net.Socket"
                  }
                }
              ],
              "desc": "<p>Alias to\n<a href=\"#netcreateconnectionport-host-connectlistener\"><code>net.createConnection(port[, host][, connectListener])</code></a>.</p>"
            }
          ]
        },
        {
          "textRaw": "`net.createConnection()`",
          "name": "createConnection",
          "type": "method",
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>A factory function, which creates a new <a href=\"#class-netsocket\"><code>net.Socket</code></a>,\nimmediately initiates connection with <a href=\"#socketconnect\"><code>socket.connect()</code></a>,\nthen returns the <code>net.Socket</code> that starts the connection.</p>\n<p>When the connection is established, a <a href=\"#event-connect\"><code>'connect'</code></a> event will be emitted\non the returned socket. The last parameter <code>connectListener</code>, if supplied,\nwill be added as a listener for the <a href=\"#event-connect\"><code>'connect'</code></a> event <strong>once</strong>.</p>\n<p>Possible signatures:</p>\n<ul>\n<li><a href=\"#netcreateconnectionoptions-connectlistener\"><code>net.createConnection(options[, connectListener])</code></a></li>\n<li><a href=\"#netcreateconnectionpath-connectlistener\"><code>net.createConnection(path[, connectListener])</code></a>\nfor <a href=\"#ipc-support\">IPC</a> connections.</li>\n<li><a href=\"#netcreateconnectionport-host-connectlistener\"><code>net.createConnection(port[, host][, connectListener])</code></a>\nfor TCP connections.</li>\n</ul>\n<p>The <a href=\"#netconnect\"><code>net.connect()</code></a> function is an alias to this function.</p>",
          "methods": [
            {
              "textRaw": "`net.createConnection(options[, connectListener])`",
              "name": "createConnection",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`options` {Object} Required. Will be passed to both the `new net.Socket([options])` call and the `socket.connect(options[, connectListener])` method.",
                      "name": "options",
                      "type": "Object",
                      "desc": "Required. Will be passed to both the `new net.Socket([options])` call and the `socket.connect(options[, connectListener])` method."
                    },
                    {
                      "textRaw": "`connectListener` {Function} Common parameter of the `net.createConnection()` functions. If supplied, will be added as a listener for the `'connect'` event on the returned socket once.",
                      "name": "connectListener",
                      "type": "Function",
                      "desc": "Common parameter of the `net.createConnection()` functions. If supplied, will be added as a listener for the `'connect'` event on the returned socket once.",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {net.Socket} The newly created socket used to start the connection.",
                    "name": "return",
                    "type": "net.Socket",
                    "desc": "The newly created socket used to start the connection."
                  }
                }
              ],
              "desc": "<p>For available options, see\n<a href=\"#new-netsocketoptions\"><code>new net.Socket([options])</code></a>\nand <a href=\"#socketconnectoptions-connectlistener\"><code>socket.connect(options[, connectListener])</code></a>.</p>\n<p>Additional options:</p>\n<ul>\n<li><code>timeout</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a> If set, will be used to call <a href=\"#socketsettimeouttimeout-callback\"><code>socket.setTimeout(timeout)</code></a> after the socket is created, but before\nit starts the connection.</li>\n</ul>\n<p>Following is an example of a client of the echo server described\nin the <a href=\"#netcreateserveroptions-connectionlistener\"><code>net.createServer()</code></a> section:</p>\n<pre><code class=\"language-mjs\">import net from 'node:net';\nconst client = net.createConnection({ port: 8124 }, () => {\n  // 'connect' listener.\n  console.log('connected to server!');\n  client.write('world!\\r\\n');\n});\nclient.on('data', (data) => {\n  console.log(data.toString());\n  client.end();\n});\nclient.on('end', () => {\n  console.log('disconnected from server');\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const net = require('node:net');\nconst client = net.createConnection({ port: 8124 }, () => {\n  // 'connect' listener.\n  console.log('connected to server!');\n  client.write('world!\\r\\n');\n});\nclient.on('data', (data) => {\n  console.log(data.toString());\n  client.end();\n});\nclient.on('end', () => {\n  console.log('disconnected from server');\n});\n</code></pre>\n<p>To connect on the socket <code>/tmp/echo.sock</code>:</p>\n<pre><code class=\"language-js\">const client = net.createConnection({ path: '/tmp/echo.sock' });\n</code></pre>\n<p>Following is an example of a client using the <code>port</code> and <code>onread</code>\noption. In this case, the <code>onread</code> option will be only used to call\n<code>new net.Socket([options])</code> and the <code>port</code> option will be used to\ncall <code>socket.connect(options[, connectListener])</code>.</p>\n<pre><code class=\"language-mjs\">import net from 'node:net';\nimport { Buffer } from 'node:buffer';\nnet.createConnection({\n  port: 8124,\n  onread: {\n    // Reuses a 4KiB Buffer for every read from the socket.\n    buffer: Buffer.alloc(4 * 1024),\n    callback: function(nread, buf) {\n      // Received data is available in `buf` from 0 to `nread`.\n      console.log(buf.toString('utf8', 0, nread));\n    },\n  },\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const net = require('node:net');\nnet.createConnection({\n  port: 8124,\n  onread: {\n    // Reuses a 4KiB Buffer for every read from the socket.\n    buffer: Buffer.alloc(4 * 1024),\n    callback: function(nread, buf) {\n      // Received data is available in `buf` from 0 to `nread`.\n      console.log(buf.toString('utf8', 0, nread));\n    },\n  },\n});\n</code></pre>"
            },
            {
              "textRaw": "`net.createConnection(path[, connectListener])`",
              "name": "createConnection",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`path` {string} Path the socket should connect to. Will be passed to `socket.connect(path[, connectListener])`. See Identifying paths for IPC connections.",
                      "name": "path",
                      "type": "string",
                      "desc": "Path the socket should connect to. Will be passed to `socket.connect(path[, connectListener])`. See Identifying paths for IPC connections."
                    },
                    {
                      "textRaw": "`connectListener` {Function} Common parameter of the `net.createConnection()` functions, an \"once\" listener for the `'connect'` event on the initiating socket. Will be passed to `socket.connect(path[, connectListener])`.",
                      "name": "connectListener",
                      "type": "Function",
                      "desc": "Common parameter of the `net.createConnection()` functions, an \"once\" listener for the `'connect'` event on the initiating socket. Will be passed to `socket.connect(path[, connectListener])`.",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {net.Socket} The newly created socket used to start the connection.",
                    "name": "return",
                    "type": "net.Socket",
                    "desc": "The newly created socket used to start the connection."
                  }
                }
              ],
              "desc": "<p>Initiates an <a href=\"#ipc-support\">IPC</a> connection.</p>\n<p>This function creates a new <a href=\"#class-netsocket\"><code>net.Socket</code></a> with all options set to default,\nimmediately initiates connection with\n<a href=\"#socketconnectpath-connectlistener\"><code>socket.connect(path[, connectListener])</code></a>,\nthen returns the <code>net.Socket</code> that starts the connection.</p>"
            },
            {
              "textRaw": "`net.createConnection(port[, host][, connectListener])`",
              "name": "createConnection",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`port` {number} Port the socket should connect to. Will be passed to `socket.connect(port[, host][, connectListener])`.",
                      "name": "port",
                      "type": "number",
                      "desc": "Port the socket should connect to. Will be passed to `socket.connect(port[, host][, connectListener])`."
                    },
                    {
                      "textRaw": "`host` {string} Host the socket should connect to. Will be passed to `socket.connect(port[, host][, connectListener])`. **Default:** `'localhost'`.",
                      "name": "host",
                      "type": "string",
                      "default": "`'localhost'`",
                      "desc": "Host the socket should connect to. Will be passed to `socket.connect(port[, host][, connectListener])`.",
                      "optional": true
                    },
                    {
                      "textRaw": "`connectListener` {Function} Common parameter of the `net.createConnection()` functions, an \"once\" listener for the `'connect'` event on the initiating socket. Will be passed to `socket.connect(port[, host][, connectListener])`.",
                      "name": "connectListener",
                      "type": "Function",
                      "desc": "Common parameter of the `net.createConnection()` functions, an \"once\" listener for the `'connect'` event on the initiating socket. Will be passed to `socket.connect(port[, host][, connectListener])`.",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {net.Socket} The newly created socket used to start the connection.",
                    "name": "return",
                    "type": "net.Socket",
                    "desc": "The newly created socket used to start the connection."
                  }
                }
              ],
              "desc": "<p>Initiates a TCP connection.</p>\n<p>This function creates a new <a href=\"#class-netsocket\"><code>net.Socket</code></a> with all options set to default,\nimmediately initiates connection with\n<a href=\"#socketconnectport-host-connectlistener\"><code>socket.connect(port[, host][, connectListener])</code></a>,\nthen returns the <code>net.Socket</code> that starts the connection.</p>"
            }
          ]
        },
        {
          "textRaw": "`net.createServer([options][, connectionListener])`",
          "name": "createServer",
          "type": "method",
          "meta": {
            "added": [
              "v0.5.0"
            ],
            "changes": [
              {
                "version": [
                  "v20.1.0",
                  "v18.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/47405",
                "description": "The `highWaterMark` option is supported now."
              },
              {
                "version": [
                  "v17.7.0",
                  "v16.15.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/41310",
                "description": "The `noDelay`, `keepAlive`, and `keepAliveInitialDelay` options are supported now."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`options` {Object}",
                  "name": "options",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`allowHalfOpen` {boolean} If set to `false`, then the socket will automatically end the writable side when the readable side ends. **Default:** `false`.",
                      "name": "allowHalfOpen",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If set to `false`, then the socket will automatically end the writable side when the readable side ends."
                    },
                    {
                      "textRaw": "`highWaterMark` {number} Optionally overrides all `net.Socket`s' `readableHighWaterMark` and `writableHighWaterMark`. **Default:** See `stream.getDefaultHighWaterMark()`.",
                      "name": "highWaterMark",
                      "type": "number",
                      "default": "See `stream.getDefaultHighWaterMark()`",
                      "desc": "Optionally overrides all `net.Socket`s' `readableHighWaterMark` and `writableHighWaterMark`."
                    },
                    {
                      "textRaw": "`keepAlive` {boolean} If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received, similarly on what is done in `socket.setKeepAlive()`. **Default:** `false`.",
                      "name": "keepAlive",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received, similarly on what is done in `socket.setKeepAlive()`."
                    },
                    {
                      "textRaw": "`keepAliveInitialDelay` {number} If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket. **Default:** `0`.",
                      "name": "keepAliveInitialDelay",
                      "type": "number",
                      "default": "`0`",
                      "desc": "If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket."
                    },
                    {
                      "textRaw": "`noDelay` {boolean} If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received. **Default:** `false`.",
                      "name": "noDelay",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received."
                    },
                    {
                      "textRaw": "`pauseOnConnect` {boolean} Indicates whether the socket should be paused on incoming connections. **Default:** `false`.",
                      "name": "pauseOnConnect",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "Indicates whether the socket should be paused on incoming connections."
                    },
                    {
                      "textRaw": "`blockList` {net.BlockList} `blockList` can be used for disabling inbound access to specific IP addresses, IP ranges, or IP subnets. This does not work if the server is behind a reverse proxy, NAT, etc. because the address checked against the block list is the address of the proxy, or the one specified by the NAT.",
                      "name": "blockList",
                      "type": "net.BlockList",
                      "desc": "`blockList` can be used for disabling inbound access to specific IP addresses, IP ranges, or IP subnets. This does not work if the server is behind a reverse proxy, NAT, etc. because the address checked against the block list is the address of the proxy, or the one specified by the NAT."
                    }
                  ],
                  "optional": true
                },
                {
                  "textRaw": "`connectionListener` {Function} Automatically set as a listener for the `'connection'` event.",
                  "name": "connectionListener",
                  "type": "Function",
                  "desc": "Automatically set as a listener for the `'connection'` event.",
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {net.Server}",
                "name": "return",
                "type": "net.Server"
              }
            }
          ],
          "desc": "<p>Creates a new TCP or <a href=\"#ipc-support\">IPC</a> server.</p>\n<p>If <code>allowHalfOpen</code> is set to <code>true</code>, when the other end of the socket\nsignals the end of transmission, the server will only send back the end of\ntransmission when <a href=\"#socketenddata-encoding-callback\"><code>socket.end()</code></a> is explicitly called. For example, in the\ncontext of TCP, when a FIN packed is received, a FIN packed is sent\nback only when <a href=\"#socketenddata-encoding-callback\"><code>socket.end()</code></a> is explicitly called. Until then the\nconnection is half-closed (non-readable but still writable). See <a href=\"#event-end\"><code>'end'</code></a>\nevent and <a href=\"https://tools.ietf.org/html/rfc1122\">RFC 1122</a> (section 4.2.2.13) for more information.</p>\n<p>If <code>pauseOnConnect</code> is set to <code>true</code>, then the socket associated with each\nincoming connection will be paused, and no data will be read from its handle.\nThis allows connections to be passed between processes without any data being\nread by the original process. To begin reading data from a paused socket, call\n<a href=\"#socketresume\"><code>socket.resume()</code></a>.</p>\n<p>The server can be a TCP server or an <a href=\"#ipc-support\">IPC</a> server, depending on what it\n<a href=\"#serverlisten\"><code>listen()</code></a> to.</p>\n<p>Here is an example of a TCP echo server which listens for connections\non port 8124:</p>\n<pre><code class=\"language-mjs\">import net from 'node:net';\nconst server = net.createServer((c) => {\n  // 'connection' listener.\n  console.log('client connected');\n  c.on('end', () => {\n    console.log('client disconnected');\n  });\n  c.write('hello\\r\\n');\n  c.pipe(c);\n});\nserver.on('error', (err) => {\n  throw err;\n});\nserver.listen(8124, () => {\n  console.log('server bound');\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const net = require('node:net');\nconst server = net.createServer((c) => {\n  // 'connection' listener.\n  console.log('client connected');\n  c.on('end', () => {\n    console.log('client disconnected');\n  });\n  c.write('hello\\r\\n');\n  c.pipe(c);\n});\nserver.on('error', (err) => {\n  throw err;\n});\nserver.listen(8124, () => {\n  console.log('server bound');\n});\n</code></pre>\n<p>Test this by using <code>telnet</code>:</p>\n<pre><code class=\"language-bash\">telnet localhost 8124\n</code></pre>\n<p>To listen on the socket <code>/tmp/echo.sock</code>:</p>\n<pre><code class=\"language-js\">server.listen('/tmp/echo.sock', () => {\n  console.log('server bound');\n});\n</code></pre>\n<p>Use <code>nc</code> to connect to a Unix domain socket server:</p>\n<pre><code class=\"language-bash\">nc -U /tmp/echo.sock\n</code></pre>"
        },
        {
          "textRaw": "`net.getDefaultAutoSelectFamily()`",
          "name": "getDefaultAutoSelectFamily",
          "type": "method",
          "meta": {
            "added": [
              "v19.4.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [],
              "return": {
                "textRaw": "Returns: {boolean} The current default value of the `autoSelectFamily` option.",
                "name": "return",
                "type": "boolean",
                "desc": "The current default value of the `autoSelectFamily` option."
              }
            }
          ],
          "desc": "<p>Gets the current default value of the <code>autoSelectFamily</code> option of <a href=\"#socketconnectoptions-connectlistener\"><code>socket.connect(options)</code></a>.\nThe initial default value is <code>true</code>, unless the command line option\n<code>--no-network-family-autoselection</code> is provided.</p>"
        },
        {
          "textRaw": "`net.setDefaultAutoSelectFamily(value)`",
          "name": "setDefaultAutoSelectFamily",
          "type": "method",
          "meta": {
            "added": [
              "v19.4.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`value` {boolean} The new default value. The initial default value is `true`, unless the command line option `--no-network-family-autoselection` is provided.",
                  "name": "value",
                  "type": "boolean",
                  "desc": "The new default value. The initial default value is `true`, unless the command line option `--no-network-family-autoselection` is provided."
                }
              ]
            }
          ],
          "desc": "<p>Sets the default value of the <code>autoSelectFamily</code> option of <a href=\"#socketconnectoptions-connectlistener\"><code>socket.connect(options)</code></a>.</p>"
        },
        {
          "textRaw": "`net.getDefaultAutoSelectFamilyAttemptTimeout()`",
          "name": "getDefaultAutoSelectFamilyAttemptTimeout",
          "type": "method",
          "meta": {
            "added": [
              "v19.8.0",
              "v18.18.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [],
              "return": {
                "textRaw": "Returns: {number} The current default value of the `autoSelectFamilyAttemptTimeout` option.",
                "name": "return",
                "type": "number",
                "desc": "The current default value of the `autoSelectFamilyAttemptTimeout` option."
              }
            }
          ],
          "desc": "<p>Gets the current default value of the <code>autoSelectFamilyAttemptTimeout</code> option of <a href=\"#socketconnectoptions-connectlistener\"><code>socket.connect(options)</code></a>.\nThe initial default value is <code>500</code> or the value specified via the command line\noption <code>--network-family-autoselection-attempt-timeout</code>.</p>"
        },
        {
          "textRaw": "`net.setDefaultAutoSelectFamilyAttemptTimeout(value)`",
          "name": "setDefaultAutoSelectFamilyAttemptTimeout",
          "type": "method",
          "meta": {
            "added": [
              "v19.8.0",
              "v18.18.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`value` {number} The new default value, which must be a positive number. If the number is less than `10`, the value `10` is used instead. The initial default value is `250` or the value specified via the command line option `--network-family-autoselection-attempt-timeout`.",
                  "name": "value",
                  "type": "number",
                  "desc": "The new default value, which must be a positive number. If the number is less than `10`, the value `10` is used instead. The initial default value is `250` or the value specified via the command line option `--network-family-autoselection-attempt-timeout`."
                }
              ]
            }
          ],
          "desc": "<p>Sets the default value of the <code>autoSelectFamilyAttemptTimeout</code> option of <a href=\"#socketconnectoptions-connectlistener\"><code>socket.connect(options)</code></a>.</p>"
        },
        {
          "textRaw": "`net.isIP(input)`",
          "name": "isIP",
          "type": "method",
          "meta": {
            "added": [
              "v0.3.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`input` {string}",
                  "name": "input",
                  "type": "string"
                }
              ],
              "return": {
                "textRaw": "Returns: {integer}",
                "name": "return",
                "type": "integer"
              }
            }
          ],
          "desc": "<p>Returns <code>6</code> if <code>input</code> is an IPv6 address. Returns <code>4</code> if <code>input</code> is an IPv4\naddress in <a href=\"https://en.wikipedia.org/wiki/Dot-decimal_notation\">dot-decimal notation</a> with no leading zeroes. Otherwise, returns\n<code>0</code>.</p>\n<pre><code class=\"language-js\">net.isIP('::1'); // returns 6\nnet.isIP('127.0.0.1'); // returns 4\nnet.isIP('127.000.000.001'); // returns 0\nnet.isIP('127.0.0.1/24'); // returns 0\nnet.isIP('fhqwhgads'); // returns 0\n</code></pre>"
        },
        {
          "textRaw": "`net.isIPv4(input)`",
          "name": "isIPv4",
          "type": "method",
          "meta": {
            "added": [
              "v0.3.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`input` {string}",
                  "name": "input",
                  "type": "string"
                }
              ],
              "return": {
                "textRaw": "Returns: {boolean}",
                "name": "return",
                "type": "boolean"
              }
            }
          ],
          "desc": "<p>Returns <code>true</code> if <code>input</code> is an IPv4 address in <a href=\"https://en.wikipedia.org/wiki/Dot-decimal_notation\">dot-decimal notation</a> with no\nleading zeroes. Otherwise, returns <code>false</code>.</p>\n<pre><code class=\"language-js\">net.isIPv4('127.0.0.1'); // returns true\nnet.isIPv4('127.000.000.001'); // returns false\nnet.isIPv4('127.0.0.1/24'); // returns false\nnet.isIPv4('fhqwhgads'); // returns false\n</code></pre>"
        },
        {
          "textRaw": "`net.isIPv6(input)`",
          "name": "isIPv6",
          "type": "method",
          "meta": {
            "added": [
              "v0.3.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`input` {string}",
                  "name": "input",
                  "type": "string"
                }
              ],
              "return": {
                "textRaw": "Returns: {boolean}",
                "name": "return",
                "type": "boolean"
              }
            }
          ],
          "desc": "<p>Returns <code>true</code> if <code>input</code> is an IPv6 address. Otherwise, returns <code>false</code>.</p>\n<pre><code class=\"language-js\">net.isIPv6('::1'); // returns true\nnet.isIPv6('fhqwhgads'); // returns false\n</code></pre>"
        }
      ],
      "displayName": "Net"
    }
  ]
}