Skip to content

Instantly share code, notes, and snippets.

@tiocadu
Last active October 11, 2017 19:22
Show Gist options
  • Save tiocadu/1ba5924f4c9291c266efceb700b52606 to your computer and use it in GitHub Desktop.
Save tiocadu/1ba5924f4c9291c266efceb700b52606 to your computer and use it in GitHub Desktop.
Cliente simples que conecta por socket e printa dados recebidos na stream - nodejs
#!/usr/bin/env node
"use strict";
// Cliente simples que conecta por socket e printa dados recebidos na stream - nodejs
var net = require('net');
var client = net.createConnection({port: 8080}, function() {
console.log('Connected to server');
});
client.on('data', function(data) {
console.log(data.toString());
});
client.on('end', function() {
console.log('Disconnected from server');
});
client.on('error', function(err) {
console.log(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment