On Tuesday, September 3, 2013 10:05:55 AM UTC-4, Felipe Silveira wrote:
>
> Hi Guys,
>
> I'm trying to implement one example of node js api and I recive this error:
>
> node.js:201
>         throw e; // process.nextTick error, or 'error' event on first tick
>               ^
> Error: connect ECONNREFUSED
>
>
Try this:

var net = require('net');
var server = net.createServer(function(c) { //'connection' listener
  console.log('Conectou ao Servidor');
  c.on('end', function() {
    console.log('Disconectou do Servidor');
  });
  console.log("Conexões: "+server.connections);
  c.write('hello\r\n');
  console.log(c);
  c.pipe(c);
});
server.listen(9118, function() { //'listening' listener
  console.log('Servidor Iniciado');
  var client = net.connect({port: 9118},
      function() { //'connect' listener
    console.log('client connected');
    client.write('world!\r\n');
  });
  client.on('data', function(data) {
    console.log(data.toString());
    client.end();
  });
  client.on('end', function() {
    console.log('client disconnected');
  });
});

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to