Skip to content

Instantly share code, notes, and snippets.

@cranic
Created March 13, 2014 16:15
Show Gist options
  • Save cranic/9531482 to your computer and use it in GitHub Desktop.
Save cranic/9531482 to your computer and use it in GitHub Desktop.
var net = require('net');
var client = new net.Socket();
client.connect(8080, '192.168.0.1');
client.on('connect', function(){
console.log('Estamos conectados');
// Aqui é o momento ideal para enviar dados;
client.write('PCCSMDR');
});
client.on('data', function(data) {
console.log('Dados recebidos', data);
});
client.on('error', function(err){
throw err;
});
client.on('close', function() {
console.log('Conexão encerrada');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment