What is the major scenario to use Socket.IO

18,556

Libraries like socket.IO are needed when we need real-time in our app. Let me explain this in little more detail. Let's assume that you are developing a game, which is multiplayer and 2 or more users can play that simultaneously. Then, in that case, you won't be making HTTP or HTTPS calls because of many reasons and one of them is that their packet size is large and other is that these calls are very slow. In such scenarios we use libraries like sockets to send and receive data to and from the server. Sockets are really fast and are capable of sending only those data packets which are needed. Using HTTP programming you can never create any multiplayer game or any app which will be interacting with a server on a realtime basis.

Let's take another example. Let's assume that you are working on a chat application. When user A is typing something then user B should know that A is typing (similar to gtalk of facebook messenger). If you will use HTTP calls at that point of time then "B" will never be able to see the actual status of the other person because of the delay. So what we can use is sockets so that when user A is typing anything then his device will send only one data packet which will just notify the server that he is typing and will be delivered to user B, this process is really fast (almost realtime) and will reduce the data transfer also.

Share:
18,556

Related videos on Youtube

Forrest
Author by

Forrest

iOS developer with 10+ years software building experience Shanghai,China Skype: forrest.shi.ef Recent App: PushUp! https://itunes.apple.com/us/app/pushup!/id750845921?mt=8

Updated on June 26, 2022

Comments

  • Forrest
    Forrest almost 2 years

    I just wonder why and for what kind of application or case we need the Socket.IO.

    I am the iOS developer of a known open source project socket.IO-objc

    Usually, we need HTTP or HTTPS to communicate with server. The socket aims to conduct real time communication (It should always keep a live HTTP connection.)

    • Schoening
      Schoening over 10 years
      Socket.IO is a very nice "boilerplate" on top of NodeJS. It uses websockets when available and has some backup methods if not available. It helps you write less code, that is more available through all browsers.
  • Schoening
    Schoening over 10 years
    It should be noted that this is also doable without Socket.IO. Modern Browsers Support Websockets. Socket.IO will use these, and can fallback on FlashSockets if needed.
  • Ginger Opariti
    Ginger Opariti over 7 years
    man, the guy that asked for advice don't need to have copy/pastes as posts