Skip to content

Commit

Permalink
doc: net.Socket in TLSSocket
Browse files Browse the repository at this point in the history
Fixes: #3963
  • Loading branch information
minervapanda committed Oct 11, 2016
1 parent 6de9d13 commit c94440b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions doc/api/tls.md
Original file line number Diff line number Diff line change
Expand Up @@ -885,9 +885,7 @@ socket.on('end', () => {
server.close();
});
```

Or

```js
const tls = require('tls');
const fs = require('fs');
Expand All @@ -911,6 +909,21 @@ socket.on('end', () => {
});
```

Note from the above example that if you don't wrap the `net.Socket` in a
`TLSSocket`, then the connect works as expected.If you're using TLS from
the start, then just use `tls.connect()`.But if you pass in a `net.Socket`,
you start the `net.Socket`.
The following explains it:

```js
var Socket = require('net').Socket;
var tls = require('tls');
var sock = new Socket();
var secureSock = tls.connect({ socket: s }, function() {
console.log("The tls socket connected. Yay!");
});
sock.connect({port: 6697, host: "irc.freenode.net"});
```

## tls.createSecureContext(options)
<!-- YAML
Expand Down

0 comments on commit c94440b

Please sign in to comment.