Skip to content

Instantly share code, notes, and snippets.

@AlexFrazer
Created August 3, 2016 14:24
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 AlexFrazer/2bc4da37f6cb49edc343b3e3585bd5b6 to your computer and use it in GitHub Desktop.
Save AlexFrazer/2bc4da37f6cb49edc343b3e3585bd5b6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
import { createConnection, createServer } from 'net';
const PORT = 3000;
const server = createServer(PORT, function () {
const { port, address } = server.address();
console.log(`Server is listening at http://${address}:${port}/`);
server.on('connection', function (connection) {
console.log(`Received new connection at ${connection.remotePort}`);
})
const interval = setInterval(function () {
createConnection(server.address());
}, 5000)
server.on('close', () => clearInterval(interval));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment