Atul Dubey
Atul Dubey

Reputation: 98

Difference between the socket , socketio, and websockets

Can someone explain me difference between socket, socketio, flask socketio with respect to python? And for using it this socket with flutter what code should I write on backend? Like I should write sever and client or only client?

Upvotes: 7

Views: 9614

Answers (3)

Michael Ade-Kunle
Michael Ade-Kunle

Reputation: 94

In a nutshell, WebSockets are a thin transport layer built on top of a device’s TCP/IP stack. The intent is to provide what is essentially an as-close-to-raw-as-possible TCP communication layer to web application developers while adding a few abstractions to eliminate certain friction that would otherwise exist concerning the way the web works. They also cater to the fact that the web has additional security considerations that must be taken into account to protect both consumers and service providers. Ably's deep dive is a brilliant resource for getting to grips with websockets: http://go.ably.com/websockets

Socket.IO is a great tool for developers wanting to set up bi-directional socket connections between client and server. This makes simple applications such as live chat much simpler to implement. Socket.IO makes many things easier and provides fallbacks for unsupported clients, but has its own trade-offs. Ably also wrote a concept piece outlining Socket.IO main use cases and how to get started: http://go.ably.com/socketio

Upvotes: 5

Miguel Grinberg
Miguel Grinberg

Reputation: 67479

A socket is one endpoint of a two-way communication link between two programs running on the network. This is a very low-level thing, everything else is implemented on top of TCP sockets.

WebSocket is a standard communication protocol for the web. It allows for a full-duplex communication channel to be established between a client and a server.

Socket.IO is a communication protocol that builds on top of HTTP and WebSocket, providing extra features such as automatic reconnection, event-based notifications, etc.

Flask-SocketIO is an implementation of the Socket.IO server-side protocol as a Flask extension.

To access a Socket.IO server from your flutter application you need to use a Socket.IO client. I do not use flutter myself, so I cannot recommend one.

Upvotes: 22

Shahnawaz Hossan
Shahnawaz Hossan

Reputation: 2720

HTTP request is something like this, if we write something on the URL or search bar using a browser then

  1. Browser sends a request to the server that is HTTP request is made to the server.
  2. Server responds to the browser with some data.

This asks for something, get something kind of system works great for a huge variety of things, like reading the news or checking the weather.

But if you want to get info more real-time, like chatting you would have to be requesting all of the time.

Websocket's purpose is to allow for a persistent' connection with a backend server so that client doesn’t have to wait for another time as the browser does.

So anyone can create a backend and frontend combination system that can very quickly and responsively react to new data as if it were a stream flowing into your client (like web client, mobile app)

You have to write both server and client to achieve real-time applications and the client needs to be connected to the server.

If you want to make a video call application then you need to exchange some info like SDP, ICE Candidate, etc. So to exchange these informations you have to develop a signaling server so that server can send these informations in real-time to its respective client.

In every platform, you can achieve socket technology. So socketio, flask socket are the different forms of the same thing in different platforms.

Upvotes: 7

Related Questions