diff --git a/doc/api/tls.md b/doc/api/tls.md index 05f584ab7127d8..fe8bfa27ef6ca2 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'); }); ```