Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: replace server.close() which don't exist in code snippets in tls.md #23239

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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