Skip to content

Commit

Permalink
doc: replace server.close() which don't exist in code snippets
Browse files Browse the repository at this point in the history
in tls.md
  • Loading branch information
oyyd committed Oct 3, 2018
1 parent 097896b commit 956567b
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 956567b

Please sign in to comment.