Skip to content

Commit

Permalink
doc: fix code snippets in tls.md
Browse files Browse the repository at this point in the history
Replace `server.close()` which don't exist in code snippets.

PR-URL: #23239
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
  • Loading branch information
oyyd authored and targos committed Oct 7, 2018
1 parent a070842 commit bd59d4e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions doc/api/tls.md
Original file line number Diff line number Diff line change
Expand Up @@ -918,9 +918,12 @@ The `callback` function, if specified, will be added as a listener for the

`tls.connect()` returns a [`tls.TLSSocket`][] object.

The following implements a simple "echo server" example:
Here is an example of a client of echo server as described in
[`tls.createServer()`][]:

```js
// This example assumes that you have created an echo server that is
// listening on port 8000.
const tls = require('tls');
const fs = require('fs');

Expand All @@ -944,13 +947,15 @@ socket.on('data', (data) => {
console.log(data);
});
socket.on('end', () => {
server.close();
console.log('client ends');
});
```

Or

```js
// This example assumes that you have created an echo server that is
// listening on port 8000.
const tls = require('tls');
const fs = require('fs');

Expand All @@ -969,7 +974,7 @@ socket.on('data', (data) => {
console.log(data);
});
socket.on('end', () => {
server.close();
console.log('client ends');
});
```

Expand Down

0 comments on commit bd59d4e

Please sign in to comment.