Example
Ajax :
- New request :
- Client sends request : Server , Do you have new notification ?
- Server sends response : Client , NO
- connection ends
- New request :
- Client sends request : Server , Do you have new notification ?
- Server sends response : Client , NO
- connection ends
- New request :
- Client sends request : Server , Do you have new notification ?
- Server sends response : Client , NO
- connection ends
- New request :
- Client sends request : Server , Do you have new notification ?
- Server sends response : Client , Yes here you are
- connection ends
you see that there is number of useless requests !
web-socket
- connection established :
- client says : Server , Do you have new notification ?
after xx time passed
after xx time passed
- Server says : Yes I have
- Client says : Server , send new email if I have
after xx time passed
- Server says : now you got new email
now the it's clear that with web-socket we won't have useless requests