Skip to content

Commit

Permalink
Fixing TLS documentation error in Issue nodejs#3963. See line 879 - 9…
Browse files Browse the repository at this point in the history
…02 in doc/api/tls.md
  • Loading branch information
VerteDinde committed Jul 3, 2017
1 parent f803e77 commit 55f3170
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions doc/api/tls.md
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,30 @@ socket.on('end', () => {
});
```

Note: When using an instance of `net.Socket`, you start the `net.Socket`. You can use `net.Socket` to upgrade an existing socket you don't wrap the `net.Socket` in a `TLSSocket`, then the connect works as expected.

See the example below for usage of upgrading an existing socket with `net.Socket`:

```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"});
```

That's typically how you upgrade an existing socket. However, if you're using TLS from the start, then just use tls.connect() to upgrade a socket:

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

## tls.connect(path[, options][, callback])
<!-- YAML
added: v0.11.3
Expand Down

0 comments on commit 55f3170

Please sign in to comment.