Skip to content
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