Created
July 29, 2010 12:31
-
-
Save termie/497993 to your computer and use it in GitHub Desktop.
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
# -- app.js -- | |
var sys = require('sys'); | |
var net = require('net'); | |
var server = net.createServer(function (stream) { | |
stream.setEncoding('utf8'); | |
setInterval(function () { | |
sys.puts('writing to stream'); | |
try { | |
if (stream.writable) { | |
stream.write('foo'); | |
} | |
} catch (e) { | |
sys.puts("caught an error!"); | |
} | |
}, 500); | |
}).listen(8181, 'localhost'); | |
var client = net.createConnection(8181, 'localhost'); | |
client.addListener('connect', function () { | |
client.destroy(); | |
}); | |
# this will result in on 1.100 | |
termie@preciousroy:~/tmp/epipe % node app.js 14:27:44 | |
writing to stream | |
writing to stream | |
events:11 | |
throw arguments[1]; | |
^ | |
Error: EPIPE, Broken pipe | |
at Stream._writeImpl (net:323:14) | |
at Stream._writeOut (net:749:25) | |
at Stream.write (net:682:17) | |
at Timer.callback (/Users/termie/tmp/epipe/app.js:10:16) | |
at node.js:255:9 | |
# and this in master HEAD | |
termie@preciousroy:~/r/node % ./build/default/node ~/tmp/epipe/app.js [master] 14:23:40 | |
writing to stream | |
writing to stream | |
events:12 | |
throw arguments[1]; | |
^ | |
Error: EPIPE, Broken pipe | |
at Stream._writeImpl (net:323:14) | |
at Stream._writeOut (net:749:25) | |
at Stream.write (net:682:17) | |
at Timer.callback (/Users/termie/tmp/epipe/app.js:9:14) | |
at node.js:267:9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment