if this is all in the same file, then your client connects to early,. the
server is not ready yet there
Am Dienstag, 3. September 2013 16:05:55 UTC+2 schrieb Felipe Silveira:
>
> 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
> at errnoException (net.js:670:11)
> at Object.afterConnect [as oncomplete] (net.js:661:19)
>
>
> The Example is:
>
> 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');
> });
>
>
> Someone know what is happening?
>
> Thank you for help!
>
--
--
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.