Skip to content

Instantly share code, notes, and snippets.

@aredridel
Created August 11, 2010 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aredridel/520037 to your computer and use it in GitHub Desktop.
Save aredridel/520037 to your computer and use it in GitHub Desktop.
buffer = new Buffer(1024 * 1024);
buffer.readFrom(socketA);
buffer.writeTo(socketB);
... is this sys.pump, with a one megabyte buffer?
Make write throw an error when it would block (making sure people handle writes in the wouldblock case, not blocking nor throwing data away)
Make an enlargeable buffer for cases where you want the old growing-memory behavior of write()
And make a non-buffering case.
Instead of either not having a buffer, or disabling it in some cases ... why not let one have control of it?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment