Most efficient method for server -> client communication?

flyingbag

Member
Licensed User
Longtime User
Currently i have the following working fine:
- Server side Socket (Java program) running on a linux box : listen mode
- Client Side Socket on android device : connects to server
- then communication happens as expected (eg send text and echo it back)

However: If i want the server to send some message to the android device (when the CLIENT is NOT connected) - what is the best way to do it?
(in other words - some kind of "push" notification)

- Timer to have client keep connecting to the server at specific intervals (seems inefficient)
- Android device can register for some intent that a request is received(is this even possible)?
- GCM (seems like one way of doing it - but not sure if this is the only way)
- Anything else?

Thanks,
flyingbag
 

ScarBelly

Member
Licensed User
Longtime User
I am doing pretty much the same thing in an intranet only environment (so no GCM possible). I am using a service with a timer to poll every 10 seconds and receive short replies (2 to 200 bytes JSON array). I have found both the processing time and power consumption to be negligible. It has been running for 8months and is rock solid. As Erel said: It depends on what you consider efficient.
 
Last edited:
Upvote 0

flyingbag

Member
Licensed User
Longtime User
OK -thanks both. I wanted to make sure before i jump into implementation to see if there is anything i am missing (besides GCM and polling)

Also - by efficient i meant how effective a polling implementation would be for process / battery time as opposed to GCM.

Looks like you have a neat solution working using polling approach - i might give this a try before looking into GCM...
 
Upvote 0
Top