Skip to content

Commit

Permalink
echo server for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
esatterwhite committed May 28, 2017
1 parent 177488a commit 223114c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions echo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict'

let count = 0
const port = process.env.PORT || 5555
const net = require('net')
const server = net.createServer((socket) => {
socket.on('data', (chunk) => {
console.log(`${++count} ` + chunk)
})
})

process.once('SIGINT', onSignal)
process.once('SIGTERM', onSignal)
server.listen(port, (err) => {
if (err) {
console.log(err)
process.exitCode = 1
}
console.log('server listening')
})
function onSignal() {
server.close()
}

0 comments on commit 223114c

Please sign in to comment.