summaryrefslogtreecommitdiff
path: root/doc/api/tls.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/api/tls.md')
-rw-r--r--doc/api/tls.md11
1 files changed, 8 insertions, 3 deletions
diff --git a/doc/api/tls.md b/doc/api/tls.md
index 292b27ae05..991c6e468f 100644
--- a/doc/api/tls.md
+++ b/doc/api/tls.md
@@ -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');
@@ -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');
@@ -969,7 +974,7 @@ socket.on('data', (data) => {
console.log(data);
});
socket.on('end', () => {
- server.close();
+ console.log('client ends');
});
```