# Web Socket

![](https://1374779285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFW3x2aqEO8GF2kr3VU%2Fuploads%2F1k1vmAC2JIfo5SLvwy1Q%2Fscreenshot-www.udemy.com-2022.11.14-13_29_19.png?alt=media\&token=085abad0-498a-4a2f-9ffe-66b44880a9e7)

* For http protocol, it is about pulling, the client make pull request and then pull the response from the server through http protocol
* Web socket protocol is established via http, it is bidirectional, the server can actively push the message to the client

![](https://1374779285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFW3x2aqEO8GF2kr3VU%2Fuploads%2Fqo4scJyhB6Un3ekoJ6Kg%2Fscreenshot-medium.com-2022.11.14-13_40_24.png?alt=media\&token=b1ab6b19-341f-40b7-842c-bd92a8a803f3)

* Firstly, client initialize the connection with server to establish the channel in order to allow constant and continuous communication over TCP connection
* A server can be connected with multiple clients
* In the channel, the message sending will be bi-directional, client can send the message to the server, and the server can also send the message to client actively

![](https://1374779285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFW3x2aqEO8GF2kr3VU%2Fuploads%2FMiez885niSmz3hRUP4Cc%2Fimage.png?alt=media\&token=cd6b8a96-f49f-4afe-ac86-73471770e8d8)

* From the inspector, it can be seen that the channel is established
* In the channel, there are pull and push messages

## Socket IO

* It is a library that abstract web socket connections
* It is required to install on both client and server-side
* Provide convenience and make it easy to setup a channel
* Demo link: [https://socketio-chat-h9jt.herokuapp.com/](https://socketio-chat-h9jt.herokuapp.com/)
