Created
November 15, 2015 20:01
-
-
Save danielrobertson/79eb7d99779bd1ecefef to your computer and use it in GitHub Desktop.
A TCP server that listens on the port given in command line arguments and writes the timestamp of connection to the connection
This file contains hidden or 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
| var net = require('net'); | |
| var port = process.argv[2]; | |
| var strftime = require('strftime'); | |
| var server = net.createServer(function (socket) { | |
| var timestamp = strftime('%F %H:%M', new Date()); | |
| console.log(timestamp); | |
| socket.write(timestamp); | |
| socket.end(); | |
| }); | |
| server.listen(port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment