SHARE
TWEET

Untitled

a guest Aug 19th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const net = require("net"), fs = require("fs");
  2.  
  3. let server, istream = fs.createReadStream("./sender/SC-02.pdf");
  4.  
  5. server = net.createServer(socket => {
  6.     socket.pipe(process.stdout);
  7.     istream.on("readable", function () {
  8.         let data;
  9.         while (data = this.read()) {
  10.             socket.write(data);
  11.         }
  12.     })
  13.     istream.on("end", function(){
  14.         socket.end();
  15.     })
  16.     socket.on("end", () => {
  17.         server.close(() => { console.log("\nTransfer is done!") });
  18.     })
  19. })
  20.  
  21. server.listen(8000, '0.0.0.0');
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