From 956567bf9178c444185d667a42a32f9a33303cc4 Mon Sep 17 00:00:00 2001 From: Ouyang Yadong Date: Wed, 3 Oct 2018 16:24:29 +0800 Subject: [PATCH] doc: replace `server.close()` which don't exist in code snippets in tls.md --- 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 292b27ae05d981..991c6e468f01f6 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'); }); ```