PHP - long polling for notifications (PHP flags or another way?)

Im starting a new project very soon, and im considering long polling to notify the users that they have a new private message/Notification that they have to check, really similar to how Facebook uses to notify you that someone has posted something about you/Liked a photo of you..

From what I have read, cometd seemed like a really good option to start with.

Then, other ways started emerging, like: Socket.io, and node.js ..

Now, my question is; Which one do you think is the best option for this case and why?

What I need to do exactly is the following;

  • User 1 logs into their account
  • User 2 sends User 1 a message which gets stored into the database and a flag is generated, (If possible?!)
  • The PHP script responsible for User 1 should pick up the flag, and push a notification to User 1

I know how to take care of the javascript side, but I have never done anything similar to long polling. Im using jQuery as javascript library and PHP for the server side.

So recommendations and any good resources to do this?

It would be beneficial to use a combination of php and also node.js. node.js is made for use with persistant connections, and push communication instead of poll.

http://nodejs.org/

Here is a quick video i found: http://vimeo.com/29099827