Skip to content

Instantly share code, notes, and snippets.

@amir-rahnama
Created November 10, 2015 23:12
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 amir-rahnama/b0a25b735f796bd69859 to your computer and use it in GitHub Desktop.
Save amir-rahnama/b0a25b735f796bd69859 to your computer and use it in GitHub Desktop.
Node.js TCP Server to generate Text Streams
// Server creates a stream of text in EXEC_INTERVAL time period
var net = require('net'),
EXEC_INTERVAL = 1000,
server = net.createServer(function(socket) {
setInterval(function() {
// Make sure data ends with a new line
socket.write('Echo ...' + '\n');
}, EXEC_INTERVAL);
}).listen(8000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment