I am writing a server for an iOS game. The game is turn based and the only time the server needs to push information to the client is to notify of the opponent\'s move.
What is Long polling ?
A variation of the traditional polling technique and allows emulation of an information push from a server to a client. With long polling, the client requests information from the server in a similar way to a normal poll.
Once the information becomes available (or after a suitable timeout), a complete response is sent to the client. The client will normally then immediately re-request information from the server, so that the server will almost always have an available waiting request that it can use to deliver data in response to an event.
In a web/AJAX context, long polling is also known as Comet programming.
What about Websockets ?
WebSockets provide a persistent connection between a client and server that both parties can use to start sending data at any time.
Conclusion :
If there is a need of Real time communication you can very well opt for websockets .
But in Long Polling :
A connection is held open between the web client and the web server so that when the server has new information it can push it to the client. That request is then finished. A new request is then made between the client and the server and then wait for another update from the server. The same TCP connection is generally open persistently throughout multiple requests due to HTTP/1.1 keep-alives.
References and other considerations :
PubNub long polling vs sockets - mobile battery life
What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?
long polling in objective-C
Websocket Introduction
Websocket Vs Long Polling
Using Websockets in Apps
Websocket Application
PushTechnology-Long Polling