Introduction to Socket.IO

Real-time | Bi-directional | Client-Server | HTML5

Udara Bibile
5 min readSep 11, 2017

Any developer working with client-server architecture ran into problem of how to push server changes to clients. The feature of communication from server to client is one of main factors in ensuring real-timeliness of client application.

There were viable options such as AJAX, long-polling, short-polling, & HTML 5 server-sent events. For comparison overview look into this stack-overflow answer.

In long-polling, client will send AJAX-like request to server. With suitable timeout, server would send back response if & when there’s update. Here the client will continuously & periodically request update from the server, through separate TCP connections, congesting network traffic.

In short-polling, client periodically send request to server asking if there’s anything new. Server doesn’t wait, but rather send back if there’s update or just empty message. Here network gets even more congested with these continuous requests, even when there’s no updates.

Short-polling vs Long-poling ( Image Source: https://hpbn.co/xmlhttprequest/ )

--

--

Udara Bibile
Udara Bibile

Responses (6)