start with understanding comet.
let say user1 wants to chat with user2. now flow will be like this:
1. user1 will type message and send it - this you can do by simple http ajax request, send message to server using ajax.
2. now server will get message from user1 and send to user2, here lies the problem, for this, you need to use server push technology. for which i have given the article above.
3. message will be shown to user2.
Note: here i have not mentioned the complexities involve in signing in by user1 and user 2, creating account etc.