Stream a file to a client.
Latest commit fb58f5a Feb 27, 2012 @mikeal Initial commit.
Failed to load latest commit information.
README.mkd Initial commit. Feb 27, 2012
client.js Initial commit. Feb 27, 2012
index.js Initial commit. Feb 27, 2012
package.json Initial commit. Feb 27, 2012
test.html Initial commit. Feb 27, 2012


siofile - read files over


  var siofile = require('siofile')

  io.sockets.on('connection', function (socket) {
    socket.on('siofile', siofile(socket))

This is incredibly insecure because it allows all clients access to your entire filesystem.


  socket.on('siofile', siofile(socket, '/home/me/myfile'))

Or you can give a list of files you want to make available.

  socket.on('siofile', siofile(socket, ['/home/me/myfile1', '/home/me/myfile2']))


  <script src="/"></script>
    var socket = io.connect('http://localhost')

    socket.on('connect', function () {
      siofile(socket).read('/home/me/myfile', function (err, data) {
        console.log(err, data)


Alternatively, you can also watch a file, which will first read the contents and then call your callback again every time new data is appended to the file. This is ideal for watching log files.

  siofile(socket).watch('/home/me/myfile', function (err, data) {
    console.log(err, data)