News for hackers. Stuff that matters.

Ask HN: Help me learn websockets.

I want to learn more about websockets and similar push technologies like polling, long polling etc.

Can you recommend any good resource/book for learning websockets using PHP/Python/JavaScript?

Also, what can be applications other than chat where one can use websockets?

( 6 comments | 18 points | on HN )
Re:Ask HN: Help me learn websockets. by pjscott on Thursday October 06, 2011 @03:42AM (#3079370)
Any time you want to be able to send messages between the browser and a server, websockets are an easy and efficient way to do it. Of course, not all browsers support them, so it's good if you can fall back to long polling. If you just want to get started hacking, socket.io is a surprisingly slick abstraction layer:

http://socket.io/

Re:Ask HN: Help me learn websockets. by anujkk on Thursday October 06, 2011 @04:26AM (#3079437)
Socket.io is nice but it requires nodejs at server side that I'm unable to use right now for some reasons. Is there any python/php alternative available?
Re:Ask HN: Help me learn websockets. by pjscott on Thursday October 06, 2011 @02:00PM (#3080975)
The best Python alternative looks like TornadIO:

https://github.com/MrJoes/tornadio

Does the same stuff as Socket.IO, but in Python. Probably not as widely used as Socket.IO, but it looks really nice.

Re:Ask HN: Help me learn websockets. by gadders on Friday October 07, 2011 @12:02PM (#3084558)
> Also, what can be applications other than chat where one can use websockets?

At a bank I used to work for they used this technique for a HTML-only trading application. The prices on the screen ticked up and down in real time without a screen refresh being required.

Re:Ask HN: Help me learn websockets. by lastkarrde on Thursday October 06, 2011 @04:35AM (#3079447)
Tornado has Websocket handling built in. It's very easy to use.

Example code: https://github.com/facebook/tornado/tree/master/demos/websoc...

Re:Ask HN: Help me learn websockets. by vonstark on Friday October 07, 2011 @04:27AM (#3083132)
web socket isn't that hard. I use it in my project. be sure what client(browsers) you are going to support, it won't work for Ie7&6 (or older chrome & ff)

1) socket.io 2) faye.jcoglan.com 3) eventmachine 4) xmpp

to use 1&2 is faster & easier, however, for example faye doesn't support event handler currently(but soon in v0.7 )

And faye also kind of hard to extend.

In my opinion, use redis(support pub/sub) & eventmachine (or something like it). to build ur backend.

use websocket-js for client.

:)