Skip to content

Commit

Permalink
doc: fix inconsistent server.listen documentation
Browse files Browse the repository at this point in the history
The `net`, `tls`, `http` and `https` module have the same
`server.listen()` method, but have a different documenation.
Changed to a consistent link to the documentation of the `net` module.

PR-URL: #16020
Backport-PR-URL: #16435
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
mgjm authored and gibfahn committed Oct 30, 2017
1 parent 4b32405 commit 9ff29eb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 119 deletions.
79 changes: 4 additions & 75 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -841,82 +841,10 @@ added: v0.1.90

Stops the server from accepting new connections. See [`net.Server.close()`][].

### server.listen(handle[, callback])
<!-- YAML
added: v0.5.10
-->

* `handle` {Object}
* `callback` {Function}

The `handle` object can be set to either a server or socket (anything
with an underlying `_handle` member), or a `{fd: <n>}` object.

This will cause the server to accept connections on the specified
handle, but it is presumed that the file descriptor or handle has
already been bound to a port or domain socket.

Listening on a file descriptor is not supported on Windows.

This function is asynchronous. `callback` will be added as a listener for the
[`'listening'`][] event. See also [`net.Server.listen()`][].

Returns `server`.

*Note*: The `server.listen()` method may be called multiple times. Each
subsequent call will *re-open* the server using the provided options.

### server.listen(path[, callback])
<!-- YAML
added: v0.1.90
-->

* `path` {string}
* `callback` {Function}

Start a UNIX socket server listening for connections on the given `path`.

This function is asynchronous. `callback` will be added as a listener for the
[`'listening'`][] event. See also [`net.Server.listen(path)`][].

*Note*: The `server.listen()` method may be called multiple times. Each
subsequent call will *re-open* the server using the provided options.

### server.listen([port][, hostname][, backlog][, callback])
<!-- YAML
added: v0.1.90
-->

* `port` {number}
* `hostname` {string}
* `backlog` {number}
* `callback` {Function}

Begin accepting connections on the specified `port` and `hostname`. If the
`hostname` is omitted, the server will accept connections on the
[unspecified IPv6 address][] (`::`) when IPv6 is available, or the
[unspecified IPv4 address][] (`0.0.0.0`) otherwise.

*Note*: In most operating systems, listening to the
[unspecified IPv6 address][] (`::`) may cause the `net.Server` to also listen on
the [unspecified IPv4 address][] (`0.0.0.0`).

Omit the port argument, or use a port value of `0`, to have the operating system
assign a random port, which can be retrieved by using `server.address().port`
after the `'listening'` event has been emitted.

To listen to a unix socket, supply a filename instead of port and hostname.

`backlog` is the maximum length of the queue of pending connections.
The actual length will be determined by the OS through sysctl settings such as
`tcp_max_syn_backlog` and `somaxconn` on linux. The default value of this
parameter is 511 (not 512).

This function is asynchronous. `callback` will be added as a listener for the
[`'listening'`][] event. See also [`net.Server.listen(port)`][].
### server.listen()

*Note*: The `server.listen()` method may be called multiple times. Each
subsequent call will *re-open* the server using the provided options.
Starts the HTTP server listening for connections.
This method is identical to [`server.listen()`][] from [`net.Server`][].

### server.listening
<!-- YAML
Expand Down Expand Up @@ -1971,6 +1899,7 @@ const req = http.request(options, (res) => {
[`response.write(data, encoding)`]: #http_response_write_chunk_encoding_callback
[`response.writeContinue()`]: #http_response_writecontinue
[`response.writeHead()`]: #http_response_writehead_statuscode_statusmessage_headers
[`server.listen()`]: net.html#net_server_listen
[`server.timeout`]: #http_server_timeout
[`setHeader(name, value)`]: #http_request_setheader_name_value
[`socket.setKeepAlive()`]: net.html#net_socket_setkeepalive_enable_initialdelay
Expand Down
39 changes: 15 additions & 24 deletions doc/api/https.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ added: v0.3.4
This class is a subclass of `tls.Server` and emits events same as
[`http.Server`][]. See [`http.Server`][] for more information.

### server.close([callback])
<!-- YAML
added: v0.1.90
-->
- `callback` {Function}

See [`server.close()`][`http.close()`] from the HTTP module for details.

### server.listen()

Starts the HTTPS server listening for encrypted connections.
This method is identical to [`server.listen()`][] from [`net.Server`][].

### server.setTimeout([msecs][, callback])
<!-- YAML
added: v0.11.2
Expand Down Expand Up @@ -90,30 +103,6 @@ https.createServer(options, (req, res) => {
}).listen(8000);
```

### server.close([callback])
<!-- YAML
added: v0.1.90
-->
- `callback` {Function}

See [`http.close()`][] for details.

### server.listen(handle[, callback])
- `handle` {Object}
- `callback` {Function}

### server.listen(path[, callback])
- `path` {string}
- `callback` {Function}

### server.listen([port][, host][, backlog][, callback])
- `port` {number}
- `hostname` {string}
- `backlog` {number}
- `callback` {Function}

See [`http.listen()`][] for details.

## https.get(options[, callback])
<!-- YAML
added: v0.3.6
Expand Down Expand Up @@ -271,6 +260,8 @@ const req = https.request(options, (res) => {
[`http.request()`]: http.html#http_http_request_options_callback
[`https.Agent`]: #https_class_https_agent
[`https.request()`]: #https_https_request_options_callback
[`net.Server`]: net.html#net_class_net_server
[`server.listen()`]: net.html#net_server_listen
[`tls.connect()`]: tls.html#tls_tls_connect_options_callback
[`tls.createSecureContext()`]: tls.html#tls_tls_createsecurecontext_options
[`tls.createServer()`]: tls.html#tls_tls_createserver_options_secureconnectionlistener
Expand Down
24 changes: 4 additions & 20 deletions doc/api/tls.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,27 +408,10 @@ added: v3.0.0
Returns a `Buffer` instance holding the keys currently used for
encryption/decryption of the [TLS Session Tickets][]

### server.listen(port[, hostname][, callback])
<!-- YAML
added: v0.3.2
-->

* `port` {number} The TCP/IP port on which to begin listening for connections.
A value of `0` (zero) will assign a random port.
* `hostname` {string} The hostname, IPv4, or IPv6 address on which to begin
listening for connections. If `undefined`, the server will accept connections
on any IPv6 address (`::`) when IPv6 is available, or any IPv4 address
(`0.0.0.0`) otherwise.
* `callback` {Function} A callback function to be invoked when the server has
begun listening on the `port` and `hostname`.

The `server.listen()` methods instructs the server to begin accepting
connections on the specified `port` and `hostname`.

This function operates asynchronously. If the `callback` is given, it will be
called when the server has started listening.
### server.listen()

See [`net.Server`][] for more information.
Starts the server listening for encrypted connections.
This method is identical to [`server.listen()`][] from [`net.Server`][].

### server.setTicketKeys(keys)
<!-- YAML
Expand Down Expand Up @@ -1292,6 +1275,7 @@ where `secure_socket` has the same API as `pair.cleartext`.
[`net.Server`]: net.html#net_class_net_server
[`net.Socket`]: net.html#net_class_net_socket
[`server.getConnections()`]: net.html#net_server_getconnections_callback
[`server.listen()`]: net.html#net_server_listen
[`tls.DEFAULT_ECDH_CURVE`]: #tls_tls_default_ecdh_curve
[`tls.TLSSocket.getPeerCertificate()`]: #tls_tlssocket_getpeercertificate_detailed
[`tls.TLSSocket`]: #tls_class_tls_tlssocket
Expand Down

0 comments on commit 9ff29eb

Please sign in to comment.