c.pipe(c) is reading from c (a single client's socket) and writing that same data back to c, so it's acting as a traditional "echo server" - if you telnet to the server, you should see any data you send echoed back to you after it sends you "hello\n".
On Wednesday, September 24, 2014 10:45:57 PM UTC-7, [email protected] wrote: > > my question is that what function of the 'c.pipe(c)' in blow program. if > no c.pipe(c), what's the difference? thanks! > var net = require('net'); > var server = net.createServer(function(c) { //'connection' listener > console.log('server connected'); > c.on('end', function() { > console.log('server disconnected'); > }); > c.write('hello\r\n'); > c.pipe(c); > }); > server.listen(8124, function() { //'listening' listener > console.log('server bound'); > }); > > -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: 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 unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/2fcd3105-aadc-4536-8573-88523411860f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
