doc: fix stylistic issues in api/net.md

* Change var to const in an example of server creation.
* Add missing semicolons.
* Use `console` syntax highlighting in `telnet` and `nc` invocation
  examples and add shell prompt symbols to be consistent with the rest
  of the documentation.

PR-URL: https://github.com/nodejs/node/pull/11786
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Alexey Orlenko 2017-03-10 12:07:15 +02:00 committed by Joyee Cheung
parent 6ff495bfde
commit d3418b1319

View File

@ -40,7 +40,7 @@ double-backslashes, such as:
```js ```js
net.createServer().listen( net.createServer().listen(
path.join('\\\\?\\pipe', process.cwd(), 'myctl')) path.join('\\\\?\\pipe', process.cwd(), 'myctl'));
``` ```
## Class: net.Server ## Class: net.Server
@ -107,7 +107,7 @@ Returns an object with `port`, `family`, and `address` properties:
Example: Example:
```js ```js
var server = net.createServer((socket) => { const server = net.createServer((socket) => {
socket.end('goodbye\n'); socket.end('goodbye\n');
}).on('error', (err) => { }).on('error', (err) => {
// handle errors here // handle errors here
@ -758,7 +758,7 @@ socket.setTimeout(3000);
socket.on('timeout', () => { socket.on('timeout', () => {
console.log('socket timeout'); console.log('socket timeout');
socket.end(); socket.end();
}) });
``` ```
If `timeout` is 0, then the existing idle timeout is disabled. If `timeout` is 0, then the existing idle timeout is disabled.
@ -997,8 +997,8 @@ server.listen(8124, () => {
Test this by using `telnet`: Test this by using `telnet`:
```sh ```console
telnet localhost 8124 $ telnet localhost 8124
``` ```
To listen on the socket `/tmp/echo.sock` the third line from the last would To listen on the socket `/tmp/echo.sock` the third line from the last would
@ -1012,8 +1012,8 @@ server.listen('/tmp/echo.sock', () => {
Use `nc` to connect to a UNIX domain socket server: Use `nc` to connect to a UNIX domain socket server:
```js ```console
nc -U /tmp/echo.sock $ nc -U /tmp/echo.sock
``` ```
## net.isIP(input) ## net.isIP(input)