DEV Community

loading...
Cover image for HTTP vs. Websockets

HTTP vs. Websockets

Anja
Software Engineer | Linux fan | lawyer | Sharing what I'm learning 😊
・1 min read

Good morning! Whats the difference between a Websocket connection and an HTTP connection?

A WebSocket enables a bidirectional communication that can send the data between the client and the server by reusing the established connection channel, meaning the connection doesnt get closed. In contrast when you use an HTTP connection you have a unidirectional communication and after each response to a request the HTTP connection gets closed.

Bidirectional means, that either the client or server can send messages to the other party, while in HTTP, the request is always initiated by the client and the response by the server. Websockets also enable full-duplex communication, which implies that the client and the server can send data to each other at the same time.

Websockets are used for example by chat apps and games. The HTTP protocol is used by RESTful APIs. If you need an explanation for REST Apis, check out my video:

www.youtube.com/watch?v=BkfNHbD2Nx4

Have a nice Sunday! :)

Discussion (0)