Last active
October 11, 2017 19:22
-
-
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
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
#!/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