Android - Sockets vs Polling

As part of the Android app I'm developing, there is a chat feature. We have a server that can process incoming messages and store messages. Is it better to maintain a socket connection between the phone and the server so that the server can send any new messages to the phone, or is it better that the phone polls the server for new chat messages?

+5
source share
3 answers

This is a bad poll solution for an application that has random data submission. I want to say that the survey data is useful when you have something that happens discretely, like every 5 minutes or something like that. this is not the case with chat, some users can send something in an hour, some can send 30 times in 2 minutes

so that your sockets open

+3
source

The survey lacks a real-time connection, and a permanent connection lacks battery power. I think what you are looking for is a push-on-and-persistant connection combination. You wake up your phone with push, and then establish a connection through sockets to handle chat.

. , c2dm google push.

+1

, , , GSM. , 10 , 3G, , WiFi.

0

All Articles