Skip to content

Instantly share code, notes, and snippets.

@gildean
Created June 9, 2013 10:34
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 gildean/5743076 to your computer and use it in GitHub Desktop.
Save gildean/5743076 to your computer and use it in GitHub Desktop.
WebM streaming from tcp to http
var net = require('net');
var server = require('http').createServer(app).listen(8000);
function app(req, res) {
if (req.url === '/') {
res.writeHead(200, {'Content-Type': 'video/webm'});
var socket = new net.Socket();
socket.connect(5000, 'localhost').pipe(res);
} else {
res.statusCode = 404;
res.end();
}
}
var fs = require('fs');
var server = require('net').createServer(function (conn) {
fs.createReadStream('./big_buck_bunny.webm').pipe(conn);
}).listen(5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment