{"id":21148,"date":"2018-03-14T12:15:13","date_gmt":"2018-03-14T10:15:13","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=21148"},"modified":"2018-03-13T10:34:52","modified_gmt":"2018-03-13T08:34:52","slug":"node-js-chat-socket-io-example-client-server","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/","title":{"rendered":"Node Js Chat Socket IO Example (Client &amp; Server)"},"content":{"rendered":"<p>This tuorial is about socket programming in NodeJs. Here we will be using socket.io and express Js to create a sample chat application. Using socket.io library for websocket connection is very simple and it is a very powerful javascript library for realtime web applications.Here, we will be creating an application where there will be a server and a client communicating with each other over websocket.<\/p>\n<h2>What is Socket.io<\/h2>\n<p>Socket.IO is a JavaScript library that provides realtime, bi-directional communication between clients and server ober websocket protocol. It has both client and server included in itself. The client side runs on browser whereas the server side requires NodeJs to run but it does not really require to have a deep knowledge of NodeJs to get started. Just include the socket.io library at server and client side and write few lines to emit and listen the different events raised by the library.<\/p>\n<h2>Environment Setup<\/h2>\n<p>First of all it is required to have Node JS and NPM installed on your machine. You can visit the <a href=\"https:\/\/nodejs.org\/en\/\" rel=\"nofollow\">Node Js<\/a> official website to download and install it or follow <a href=\"http:\/\/blog.teamtreehouse.com\/install-node-js-npm-windows\" rel=\"nofollow\">this<\/a> link to set up on your local machine.Now once this setup is done we can install express and socket.io library in our machine to get started.Express Js is a lightweight, open source framework for Node Js. Similarly, npm is a package manager for the JavaScript programming language. It is the default package manager for Node.js.<\/p>\n<p>Now let&#8217;s create our chat application. Execute following commands to create a blank project and include all the required dependencies such as socket.io and express required for our project.<\/p>\n<pre class=\"brush:php\">C:\\D\\workspaces\\node&gt;mkdir chat-app\r\nC:\\D\\workspaces\\node&gt;cd chat-app\r\nC:\\D\\workspaces\\node\\chat-app&gt;npm init\r\nC:\\D\\workspaces\\node\\chat-app&gt;npm install socket.io express --save\r\nnpm install socket.io --save<\/pre>\n<h2>Node Js Express App<\/h2>\n<p>Now we will create a sample node app using express to serve a static .html file.Import the project in your favourite IDE and add a file name index.js add following lines in it.<\/p>\n<pre class=\"brush:js\">var app = require('express')();\r\nvar http = require('http').Server(app);\r\n\r\napp.get('\/', function(req, res){\r\n  res.send('&lt;h1&gt;Hello world&lt;\/h1&gt;');\r\n});\r\n\r\nhttp.listen(3000, function(){\r\n  console.log('listening on *:3000');\r\n});<\/pre>\n<p>Above code will initialise express and create a server that is listening on port 3000 and for a request at <a>localhost:3000<\/a> Hello world will be served.<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2018\/03\/P3MxUqE.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-21153\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2018\/03\/P3MxUqE.png\" alt=\"\" width=\"533\" height=\"264\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2018\/03\/P3MxUqE.png 533w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2018\/03\/P3MxUqE-300x149.png 300w\" sizes=\"(max-width: 533px) 100vw, 533px\" \/><\/a><\/p>\n<p>Now let us modify the code to serve a html.Create chat.html and add following lines to it.<\/p>\n<pre class=\"brush:xml\">&lt;body&gt;\r\n&lt;ul id=\"messages\"&gt;&lt;\/ul&gt;\r\n&lt;form action=\"\"&gt;\r\n    &lt;input id=\"m\" autocomplete=\"off\" \/&gt;&lt;button&gt;Send&lt;\/button&gt;\r\n&lt;\/form&gt;\r\n&lt;\/body&gt;<\/pre>\n<p>This will create a simple form to enter message in the client side.<\/p>\n<h2>Integrating Socket.io<\/h2>\n<p>Now add following lines in index.js which will initialize a new instance of socket.io by passing the http object.<\/p>\n<pre class=\"brush:js\">var io = require('socket.io')(http);<\/pre>\n<p>Whenever a client gets connected to a socket a connection event is raised and following code will listen to this event and logs the event for every new connection.<\/p>\n<pre class=\"brush:php\">io.on('connection', function(socket){\r\n  console.log('a user connected');\r\n});<\/pre>\n<p>Now let us integrate socket in the client side. Add following lines in chat.html before the tag. It will expose a global variable io and connect to the host that serves the page.Once a client gets connected in the browser, connect event is triggered and on a successful connection in the client side, client emits an event &#8211; joined which has a callback to send data to the server. And the server that is listening for the event &#8211; joined will receive the same data.<\/p>\n<p><b>chat.html<\/b><\/p>\n<pre class=\"brush:xml\">&lt;script src=\"\/socket.io\/socket.io.js\"&gt;&lt;\/script&gt;\r\n&lt;script&gt;\r\n  var socket = io();\r\n  socket.on('connect', function(data) {\r\n    socket.emit('joined', 'Hello World from client');\r\n });\r\n&lt;\/script&gt;<\/pre>\n<p><b>index.js<\/b><\/p>\n<pre class=\"brush:js\">io.on('connection', function(socket){\r\n    console.log('a user connected');\r\n    socket.on('joined', function(data) {\r\n        console.log(data);\r\n    });\r\n});<\/pre>\n<p>Now, once server finds that a new client has joined it will acknowledge the same to the client.<\/p>\n<p><b>index.js<\/b><\/p>\n<pre class=\" brush:php\">socket.on('joined', function(data) {\r\n        console.log(data);\r\n\t\tsocket.emit('acknowledge', 'Acknowledged');\r\n    });<\/pre>\n<p><b>chat.html<\/b><\/p>\n<pre class=\"brush:js\">socket.on('acknowledge', function(data) {\r\n        alert(data);\r\n    });<\/pre>\n<p>This completes the initial binding between client and server.Now let us make provision for the chat between client and server.Whenever a client enters any message in the text box and hits enter, chat message event will be raised by the client and the server is listening to the same event. Whenever server finds any event with chat message, it will append &#8216;from server &#8216; in the message and emit &#8216;response message&#8217; and the client will be listening to this event again and accordingly the chat window will be updated.<br \/>\n<ins><\/ins><\/p>\n<p><b>chat.html<\/b><\/p>\n<pre class=\"brush:js\">$('form').submit(function(){\r\n      socket.emit('chat message', $('#m').val());\r\n      $('#m').val('');\r\n      return false;\r\n    });\r\n  });<\/pre>\n<p><b>index.js<\/b><\/p>\n<pre class=\"brush:js\">socket.on('chat message', function(msg){\r\n        console.log('message: ' + msg);\r\n    });<\/pre>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2018\/03\/WWSZfAA.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-21154\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2018\/03\/WWSZfAA.png\" alt=\"\" width=\"563\" height=\"477\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2018\/03\/WWSZfAA.png 563w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2018\/03\/WWSZfAA-300x254.png 300w\" sizes=\"(max-width: 563px) 100vw, 563px\" \/><\/a><\/p>\n<h2>Broadcasting Message<\/h2>\n<p>Above configuration will enable chat between a client and a server. We can also broadcast a same message to all the connected clients. For this purpose, we have broadcast flag.<\/p>\n<p><b>index.js<\/b><\/p>\n<pre class=\"brush:js\">socket.broadcast.emit('response message', msg + '  from server');<\/pre>\n<h2>Conclusion<\/h2>\n<p>I hope this article served you that you were looking for. If you have anything that you want to add or share then please share it below in the <b>comment section<\/b>.You can download the source code from <a href=\"https:\/\/github.com\/only2dhir\/node-socket-example\" rel=\"nofollow\">github<\/a>.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>Published on Web Code Geeks with permission by Dhiraj Ray, partner at our <a href=\"\/\/www.webcodegeeks.com\/join-us\/wcg\/\" target=\"_blank\" rel=\"noopener\">WCG program<\/a>. See the original article here: <a href=\"http:\/\/www.devglan.com\/node-js\/nodejs-chat-socket-io-example\" target=\"_blank\" rel=\"noopener\">Node Js Chat Socket IO Example(Client + Server)<\/a><\/p>\n<p>Opinions expressed by Web Code Geeks contributors are their own.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This tuorial is about socket programming in NodeJs. Here we will be using socket.io and express Js to create a sample chat application. Using socket.io library for websocket connection is very simple and it is a very powerful javascript library for realtime web applications.Here, we will be creating an application where there will be a &hellip;<\/p>\n","protected":false},"author":4240,"featured_media":924,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-21148","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-node-js"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Node Js Chat Socket IO Example (Client &amp; Server) - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"This tuorial is about socket programming in NodeJs. Here we will be using socket.io and express Js to create a sample chat application. Using socket.io\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Node Js Chat Socket IO Example (Client &amp; Server) - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"This tuorial is about socket programming in NodeJs. Here we will be using socket.io and express Js to create a sample chat application. Using socket.io\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/dhiraj.ray.39\" \/>\n<meta property=\"article:published_time\" content=\"2018-03-14T10:15:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Dhiraj Ray\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@only2dhir\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dhiraj Ray\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/\"},\"author\":{\"name\":\"Dhiraj Ray\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a4f9c7dac43a0f90721501e48faf1a0e\"},\"headline\":\"Node Js Chat Socket IO Example (Client &amp; Server)\",\"datePublished\":\"2018-03-14T10:15:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/\"},\"wordCount\":756,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg\",\"articleSection\":[\"Node.js\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/\",\"name\":\"Node Js Chat Socket IO Example (Client &amp; Server) - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg\",\"datePublished\":\"2018-03-14T10:15:13+00:00\",\"description\":\"This tuorial is about socket programming in NodeJs. Here we will be using socket.io and express Js to create a sample chat application. Using socket.io\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Node.js\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/node-js\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Node Js Chat Socket IO Example (Client &amp; Server)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a4f9c7dac43a0f90721501e48faf1a0e\",\"name\":\"Dhiraj Ray\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1ec5d4a3295c99de70fc9b4f0ab3f8cd1a8ff127aa81e43163f75b5dc32cf906?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1ec5d4a3295c99de70fc9b4f0ab3f8cd1a8ff127aa81e43163f75b5dc32cf906?s=96&d=mm&r=g\",\"caption\":\"Dhiraj Ray\"},\"description\":\"He is a technology savvy professional with an exceptional capacity to analyze, solve problems and multi-task. He is an avid reader and a technology enthusiast who likes to be up to date with all the latest advancements happening in the techno world. He also runs his own blog @ devglan.com\",\"sameAs\":[\"http:\/\/www.devglan.com\/\",\"https:\/\/www.facebook.com\/dhiraj.ray.39\",\"https:\/\/www.linkedin.com\/in\/dhiraj-ray-devglan\/\",\"https:\/\/x.com\/only2dhir\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/dhiraj-ray\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Node Js Chat Socket IO Example (Client &amp; Server) - Web Code Geeks - 2026","description":"This tuorial is about socket programming in NodeJs. Here we will be using socket.io and express Js to create a sample chat application. Using socket.io","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/","og_locale":"en_US","og_type":"article","og_title":"Node Js Chat Socket IO Example (Client &amp; Server) - Web Code Geeks - 2026","og_description":"This tuorial is about socket programming in NodeJs. Here we will be using socket.io and express Js to create a sample chat application. Using socket.io","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_author":"https:\/\/www.facebook.com\/dhiraj.ray.39","article_published_time":"2018-03-14T10:15:13+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg","type":"image\/jpeg"}],"author":"Dhiraj Ray","twitter_card":"summary_large_image","twitter_creator":"@only2dhir","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Dhiraj Ray","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/"},"author":{"name":"Dhiraj Ray","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a4f9c7dac43a0f90721501e48faf1a0e"},"headline":"Node Js Chat Socket IO Example (Client &amp; Server)","datePublished":"2018-03-14T10:15:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/"},"wordCount":756,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg","articleSection":["Node.js"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/","name":"Node Js Chat Socket IO Example (Client &amp; Server) - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg","datePublished":"2018-03-14T10:15:13+00:00","description":"This tuorial is about socket programming in NodeJs. Here we will be using socket.io and express Js to create a sample chat application. Using socket.io","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/node-js-chat-socket-io-example-client-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"Node.js","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/node-js\/"},{"@type":"ListItem","position":4,"name":"Node Js Chat Socket IO Example (Client &amp; Server)"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a4f9c7dac43a0f90721501e48faf1a0e","name":"Dhiraj Ray","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1ec5d4a3295c99de70fc9b4f0ab3f8cd1a8ff127aa81e43163f75b5dc32cf906?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1ec5d4a3295c99de70fc9b4f0ab3f8cd1a8ff127aa81e43163f75b5dc32cf906?s=96&d=mm&r=g","caption":"Dhiraj Ray"},"description":"He is a technology savvy professional with an exceptional capacity to analyze, solve problems and multi-task. He is an avid reader and a technology enthusiast who likes to be up to date with all the latest advancements happening in the techno world. He also runs his own blog @ devglan.com","sameAs":["http:\/\/www.devglan.com\/","https:\/\/www.facebook.com\/dhiraj.ray.39","https:\/\/www.linkedin.com\/in\/dhiraj-ray-devglan\/","https:\/\/x.com\/only2dhir"],"url":"https:\/\/www.webcodegeeks.com\/author\/dhiraj-ray\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/21148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/4240"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=21148"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/21148\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/924"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=21148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=21148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=21148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}