Created
September 3, 2012 17:53
-
-
Save joeegan/3611355 to your computer and use it in GitHub Desktop.
simple tcp server that writes the data posted to it to an output file
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 fs = require('fs'), | |
| net = require('net'); | |
| var writeStream = fs.createWriteStream(__dirname + "/outfile.txt"); | |
| var server = net.createServer(function (socket) { | |
| socket.on('data', function(data) { | |
| socket.write(data); | |
| writeStream.write(data); | |
| console.log(data); | |
| }); | |
| }); | |
| server.listen(1337, "localhost"); | |
| console.log("TCP server listening on port 1337 at localhost."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment