Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between express and socketio for nodejs

I am new to nodejs programming and going through various js that are being developed for node. My question is a basic one. Can someone please explain me the difference between express and socketio.

From what I know, express is a middleware on which we can use template engines like jade to push data to browser. What does socketio do then? Is it a transport layer? It is confusing to me to understand the difference and why we need express and socket in nodejs apps.

like image 248
Gaurav Mehta Avatar asked Nov 15 '13 22:11

Gaurav Mehta


People also ask

What is Socket.IO VS Express?

Express http server gives request response model from client to server. Socket.io enables bidirectional communication channel between client and server.

What is the difference between Express and node?

NodeJS is an event-driven, non-blocking I/O model using JavaScript as its main language. It helps to build scalable network applications. Express is a minimal and flexible Node. js web application framework that provides a robust set of features for web and mobile applications.

Can I use Socket.IO with Express?

Socket.IO can be used based on the Express server just as easily as it can run on a standard Node HTTP server. In this section, we will fire the Express server and ensure that it can talk to the client side via Socket.IO.

What is the difference between Nextjs and express JS?

Express is a minimal and flexible node. js web application framework, providing a robust set of features for building single and multi-page, and hybrid web applications; Next. js: *A small framework for server-rendered universal JavaScript apps *.


1 Answers

Express is an application server. You define routes and write code to generate your application's pages or API responses. It is basically a port of a ruby project called Sinatra. It works for a traditional request/response HTTP model.

Socket.io is there to help you implement a server push model for real time type features such as alerts/notifications, chat, or whatever updates you want to do if you want them to just show up in the browser without waiting for the user to click a "refresh" button or anything like that.

like image 162
Peter Lyons Avatar answered Sep 22 '22 19:09

Peter Lyons