From bd59d4efbf30bdb6136c33626aa9f8a7b2375e13 Mon Sep 17 00:00:00 2001 From: Ouyang Yadong Date: Wed, 3 Oct 2018 16:24:29 +0800 Subject: [PATCH] doc: fix code snippets in tls.md Replace `server.close()` which don't exist in code snippets. PR-URL: https://github.com/nodejs/node/pull/23239 Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott Reviewed-By: Denys Otrishko Reviewed-By: Vse Mozhet Byt --- doc/api/tls.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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'); }); ```