A simple chat application using Node.js

Posted by midhun pottmmal On Monday, 21 April 2014 0 comments
     Node Js gives ability for JavaScript to write back end code .It is one of the perfect technologies for real time application .Now we discussing how to write a simple chat server ad client using node js .

Download code
       
Steps

  1. Install and setup node js
  2. Create a TCP server
  3. Create a TCP client
  Install and setup node

       First step on node is how to setup a node.js platform ,now i am only discussing on windows .node supports windows OS since 0.6 version ,for installing go to node.js website and from download tab download  http://nodejs.org/download/ windows .msi installer .After down loading run the installer and click next and install node ,it will show a conform message after it install properly 



now you installed node properly now we want to know node  is working properly or note 

   go to cmd and type node -v


Create TCP server 

   Node has a first-class HTTP server implementation in the form of a pseudo-class in http .Server, which descends from the TCP server pseudo-class in net.Server. This means that everything described in this chapter applies to the Node HTTP server as well.

  • You can create a TCP server using the net module
         




  now we just create a node js server and u can connect client through the port 4001 , using telnet

 



now these things are working proper you finished how to set up a simple TCP server using node and how to connect that TCP port using telnet


Building a simple tcp server have flowing steps

  1. Create a tcp server
  2. Accept connection
  3. Receiving client data 
  4. Collecting all the clients
  5. Broadcasting data 

            1.Create a tcp server
    
                         

            2.Accept connection


          3 Receiving client data
       
        4.Collecting all clients

     
         5. Broadcasting



These are the steps for creating tcp chat server . in this project i am attaching a full set of working TCP server and TCP client with this post .

Download code

0 comments:

Post a Comment

Fashion