Skip to content

Instantly share code, notes, and snippets.

@moleike moleike/ipc.js
Last active Aug 2, 2017

Embed
What would you like to do?
const net = require('net');
const server = net.createServer((c) => {
// 'connection' listener
console.log('client connected');
c.on('end', () => {
console.log('client disconnected');
});
c.write('hello');
c.pipe(c);
});
server.on('error', (err) => {
throw err;
});
server.listen('/tmp/echo.sock', () => {
console.log('server bound');
});
const client = net.createConnection({
path: '/tmp/echo.sock'
}, () => {
//'connect' listener
console.log('connected to server!');
client.write('world!\r\n');
});
client.on('data', (data) => {
console.log(data.toString());
client.end();
});
client.on('end', () => {
console.log('disconnected from server');
});
var proxy = require('dtls-proxy');
const options = {
backend: 'localhost:3000', // or '/tmp/backend.sock'
key: fs.readFileSync('server-key.pem'),
cert: fs.readFileSync('server-cert.pem'),
};
const server = proxy.createServer(options);
server.listen(5683);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.