Skip to content

Instantly share code, notes, and snippets.

@sgnl
Created January 9, 2016 21:51
Show Gist options
  • Save sgnl/69f60909ef83b73a3b10 to your computer and use it in GitHub Desktop.
Save sgnl/69f60909ef83b73a3b10 to your computer and use it in GitHub Desktop.
Process & Net client starter pack
const Net = require('net');
// Server is actually this client
const Server = Net.connect({host: 'localhost', port: 6969}, function() {
process.stdin.setEncoding('utf8');
Server.setEncoding('utf8');
process.stdout.write('SGNL: ');
process.stdin.on('data', function(data) {
Server.write(data);
});
Server.on('data', function(data) {
process.stdout.write('\r' + data + '\nSGNL: ');
});
});
const Net = require('net');
const Server = Net.createServer(function(client) {
client.write('WELCOME!!!!');
});
Server.listen(6969, function() {
console.log('SERVER IS UP');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment