Here are the links to the previous installments:
- Introduction
- Threads vs. Events
- Using Non-Standard Modules
- Debugging with node-inspector
- CommonJS and Creating Custom Modules
- Node Version Management with n
- Implementing Events
- BDD Style Unit Tests with Jasmine-Node Sprinkled With Some Should
- ?node_modules? Folders
- Pumping Data Between Streams
- Some Node.js Goodies
- The Towering Inferno
Just a quick post to show that although creating HTTP servers clearly dominates most code samples that demonstrate the use of Node.js, that it?s also possible to create TCP servers using Node.js.
var net = require(?net?); net.createServer(function(socket)) { socket.on('data', function(data) { socket.write(data); }); } .listen(2500);
This code sample isn?t very useful in and of itself except for the fact that it demonstrates that it?s just as easy to create a TCP server as it is to create an HTTP server with Node.js.
There! Feeling all better now :-).