Stackoverflow实时更新如何工作?

Here is the screenshot taken from questions tagged with PHP.

enter image description here

So, If I open this page and leave it without refresh for some minutes it appers

x questions with new activity

And when I click it, It display all latest updates. I want to write similar script for news updates. Is it using JavaScript setTimeout to poll the server and embed the updates to <div>?

websockets

StackExchange.realtime.init('ws://sockets.ny.stackexchange.com:80');

http://socket.io/