Thursday, 26 March 2020

Websockets Vs Sockets - a simple explanation


Note : TCP/IP is a different stack and a practical version of OSI model . It doesn't implement all layers of OSI models.

Read this article on geeksforgeeks : < https://www.geeksforgeeks.org/tcp-ip-model/ >.
I was able to recollect all my readings in below image :


Some plain simple examples where sockets are used is real time chat , cricket scores , stock market data etc.
If you see something changing on page being changed without page reloading it could be web socket , although there are many other technologies like AJAX.

Important points to consider :

1) Plain sockets are based on TCP/IP , they are often called TCP/IP socket. Both sockets have same purpose allow stream of data without continuous hand shaking.

2) Websockets were designed as web browsers didn't had support for TCP/IP socket , as most of the webbrower as you know work on application layer.

3) Today many browsers support web sockets , however now there are many non-browser based clients exists for web-sockets.

Important : You may not need websocket all the time . websockets have additional overhead compared to sockets , so you might consider TCP/IP sockets if you are working in non-browser environment.

Also , the new buzz is socket.io , if you would like to read about it let me know.

No comments:

Post a Comment