Last active
May 21, 2021 09:03
-
-
Save dcmwong/b4175e2f5aca007a0aa6ea405e05b56d to your computer and use it in GitHub Desktop.
simple send message to tls server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as fs from 'fs' | |
import * as tls from 'tls' | |
var conn = tls.connect(1234, 'localhost', {}, function () { | |
if (conn.authorized) { | |
console.log('Connection authorized by a Certificate Authority.') | |
conn.write('hello from the client') | |
} else { | |
console.log('Connection not authorized: ' + conn.authorizationError) | |
} | |
}) | |
conn.on('data', function (data) { | |
console.log(data.toString()) | |
conn.end() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment