title: node.js how to read file in stream from remote server
body: <p>In node.js I am trying to watch and read a text file on filechange.For this, I am using below code and it is working absolutely fine.</p>
  
  <pre><code>var fs = require('fs'),bite_size = 256,readbytes = 0,file;
  fs.open('testread.txt', 'r', function(err, fd) {
      file = fd; //readsome(); 
  
      var func = (function readsome() {
      var stats = fs.fstatSync(file); // yes sometimes async does not make sense!
      if(stats.size&lt;readbytes+1) {        
          setTimeout(readsome, 1000);
      }
      else {
          fs.read(file, new Buffer(bite_size), 0, bite_size, readbytes, function (err, bytecount, buff) {
          console.log(buff.toString('utf-8', 0, bytecount));
          readbytes+=bytecount;
          process.nextTick(readsome);
          });
      }
      })();   
  });
  </code></pre>
  
  <p>But this works only for local file and now I need to read text file from remote server ( may be linux or windows) in same way. </p>
  
  <p>Please help , how can I use remote server login information like below</p>
  
  <pre><code>IP address = "XXX.XXX.XX.XX";, 
  username = username, 
  password = password, 
  filepath = "/root/testread.txt" or "D:\testread.txt" 
  </code></pre>
  
  <p>and read the data from text file present at filepath in remote server.  </p>