notexOPENOverview
Notex/Systems/WebSocket
12.06LESSON 06 OF 13 · 1 MIN READ

WebSocket

Always free to read
SECTION VIDEOWebSocket

Video coming soon. Start with the reading below.

COMING SOON

WebSocket is the most common solution for sending asynchronous updates from server to client. Figure 12-5 shows how it works.

Design a chat system — original diagram 149

WebSocket connection is initiated by the client. It is bi-directional and persistent. It starts its life as a HTTP connection and could be “upgraded” via some well-defined handshake to a WebSocket connection. Through this persistent connection, a server could send updates to a client. WebSocket connections generally work even if a firewall is in place. This is because they use port 80 or 443 which are also used by HTTP/HTTPS connections.

Earlier we said that on the sender side HTTP is a fine protocol to use, but since WebSocket is bidirectional, there is no strong technical reason not to use it also for sending. Figure 12-6 shows how WebSockets (ws) is used for both sender and receiver sides.

Design a chat system — original diagram 150

By using WebSocket for both sending and receiving, it simplifies the design and makes implementation on both client and server more straightforward. Since WebSocket connections are persistent, efficient connection management is critical on the server-side.

Progress is saved on this device.
KEEP EXPLORING

One note leads to another.

Back to the library →
⌕
Search across the entire library ⌘ K