DEV Community

loading...

Web socket and HTTP(s); Intro to simple differences

eulier profile image Eulier Gonzalez ・Updated on ・1 min read

In telecommunication a duplex communication system is a point to point system composed of 2 or more connected devices.
And it can be:

  • Full-duplex system, simultaneously or bi-directional at time
    Screenshot_2021-04-20 Duplex (telecommunications) - Wikipedia(1)

  • Half-duplex system, communication is one direction at time
    Screenshot_2021-04-20 Duplex (telecommunications) - Wikipedia

HTTP 1.1, HyperText Transfer Protocol is a Half-duplex system.

So writing chat applications using i.e. LAMP Stack, (Linux, Apache, Mysql & PHP), it involve:

  • Actively sampling the status of the server (Polling) for changes
  • Keep track timestamp and
  • It’s slower than it should be.

Socket have traditionally been the solution for real-time chat application are architected, supplying a bi-directional (Full-duplex) communication channel between the client and the server. It actually use the URI format.

ws://userinfo@host:port/path?query#fragment
Enter fullscreen mode Exit fullscreen mode

This is just a start to wrap your mind around in case you want to understand how socket.io

It also contains very helpful examples

Discussion (2)

pic
Editor guide
Collapse
netikras profile image
Darius Juodokas

HTTP, HyperText Transfer Protocol is a Half-duplex system

Is it though? AFAIK http/1.1 can write responses while the request is still being sent, and with http/2 the bidirectional communication becomes even more obvious (ref: http2.github.io/http2-spec/#Stream...).

I could be wrong so please, correct me if I am.

Collapse
eulier profile image
Eulier Gonzalez Author • Edited

I already update the post. It's HTTP/1.1 which behave as a half-duplex, it can be use as a full-duplex using http polling, but acording to the Socket.io docs, it's more slower than it should be, when writing chat applications.