Created
August 3, 2016 14:24
-
-
Save AlexFrazer/2bc4da37f6cb49edc343b3e3585bd5b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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