SHARE
TWEET

Untitled

a guest Aug 19th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const net = require("net"), fs = require("fs"), remote_server = process.argv[2];
  2. let socket;
  3.  
  4. socket = remote_server ? net.connect(8000, remote_server) : net.connect(8000);
  5.  
  6. let ostream = fs.createWriteStream("./receiver/SC-02.pdf");
  7. let date = new Date(), size = 0, elapsed;
  8. socket.on('data', chunk => {
  9.   size += chunk.length;
  10.   elapsed = new Date() - date;
  11.   socket.write(`\r${(size / (1024 * 1024)).toFixed(2)} MB of data was sent. Total elapsed time is ${elapsed / 1000} s`)
  12.   process.stdout.write(`\r${(size / (1024 * 1024)).toFixed(2)} MB of data was sent. Total elapsed time is ${elapsed / 1000} s`);
  13.   ostream.write(chunk);
  14. });
  15. socket.on("end", () => {
  16.   console.log(`\nFinished getting file. speed was: ${((size / (1024 * 1024)) / (elapsed / 1000)).toFixed(2)} MB/s`);
  17.   process.exit();
  18. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top