Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Introduction to Node.js

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 797
    Comment on it

    Introduction

     

    Node.js is an open source, cross platform JavaScript runtime built on top of Google's V8 JavaScript Engine . It was originally written by  Ryan Dahl. Node.js uses an event driven  nonblocking I/O model that makes it lightweight and suitable for  building fast and scalable applications. In addition to JavaScript runtime Node.js also provides an extensive library of various JavaScript modules which greatly facilitates the development of applications.     

     

    Hence we can summarize Node.js as below:

    Node.js = JavaScript Runtime Environment + JavaScript Library


    Installing Node


    Node.js is very easy to install.The installers are available on the download page : https://nodejs.org/download/.


    Hello World Examples:

     

    Let's now go through some simple Hello World examples to understand the basics of Node.js

     

    Using HTTP:

    // Load http module to create an http server.
    var http = require('http');
    
    
    // Configure the  HTTP server to respond with Hello World
    http.createServer(function (request, response) {
        response.writeHead(200, {'Content-Type': 'text/plain'});
        response.end('Hello World\n');
    }).listen(8080);
    
    
    // Listen on port 8080 (Defaults IP : 127.0.0.1)
    console.log('Server started');

     

    Using TCP:

     

    // Load net module to create a TCP server.
    var net = require('net');
    
    
    // Create a new TCP server.
    var server = net.createServer(function (socket) {
    
    //On connection, tell "Hello World" and then close the connection.
    console.log("Connection " + socket.remoteAddress);
    socket.end("Hello World\n");
    
    });
    
    // Start up and listen on port 8000 on localhost
    server.listen(8000, "localhost");

     

    Summary :


    Node.js is currently being used by some of the biggest brands in the world like Microsoft , Yahoo , Oracle and eBay to name a few. Hope the above article helps you in starting with Node.js platform.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: