Created
July 12, 2014 08:35
-
-
Save pbrewczynski/04a7f4ccf33a560227f7 to your computer and use it in GitHub Desktop.
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
// Wrong example // Load the net module to create a tcp server. | |
var net = require('net'); | |
// Setup a tcp server | |
var server = net.createServer(function (socket) { | |
// Every time someone connects, tell them hello and then close the connection. | |
socket.addListener("connect", function () { | |
sys.puts("Connection from " + socket.remoteAddress); | |
socket.end("Hello World\n"); | |
}); | |
}); | |
// Fire up the server bound to port 7000 on localhost | |
server.listen(7000, "localhost"); | |
// Put a friendly message on the terminal | |
console.log("TCP server listening on port 7000 at localhost."); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment