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: nodejs#23239
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Vse Mozhet Byt <[email protected]>
  • Loading branch information
oyyd authored and vsemozhetbyt committed Oct 5, 2018
1 parent a8526cb commit 0544816
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 0544816

Please sign in to comment.