Skip to content

Instantly share code, notes, and snippets.

@horatio-sans-serif
Created May 10, 2010 20:56
Show Gist options
  • Save horatio-sans-serif/396533 to your computer and use it in GitHub Desktop.
Save horatio-sans-serif/396533 to your computer and use it in GitHub Desktop.
var sys = require('sys'),
net = require('net'),
server = net.createServer(function (c) {
var input = '';
c.setEncoding('utf8');
c.addListener("data", function (chunk) {
input += chunk;
var match;
while (match = input.match(/^(.+)\r\n/)) {
input = input.substr(match[0].length);
var line = match[1];
sys.puts("LINE: " + line);
}
});
}).listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment