0

I have an Android client that needs to request information from my server. The information on my server is updated randomly and can be updated every second or minute. Communication is done via raw TCP/IP. My current method of is having the Android client request the info every few seconds on a loop. Is there a more efficient way of doing this? Would having the client request it every second kill battery? It's something like this:

  1. Open connection to server
  2. Send request message
  3. Server responds
  4. Client closes connection
  5. Repeat after 5 seconds
John
  • 1

1 Answers1

-2

Why doesn't your server sends a notification when this event happens? I mean using GCM. Follow the guide there, it will help you.

bryant1410
  • 3,888
  • 1
  • 33
  • 34
  • I'd like to stick to raw TCP/IP if possible for simplicity. – John Aug 26 '15 at 01:26
  • @John: Why raw TCP/IP? – bryant1410 Aug 26 '15 at 01:28
  • Just for simplicity. If it can't be done simply on TCP/IP I'll look into GCM. – John Aug 26 '15 at 01:29
  • I think GCM is a very simple approach. The messages are light too. It's what everyday apps do. For example, a chat app sends a push notification each time a new message is sent. If the content is large, you can use the push message to notify (maybe with a url) and then the client requests something to the server. – bryant1410 Aug 26 '15 at 01:32
  • @bryant1410 hi bryant, do you know how to overcome delays on gcm ? Thanks – Melvin Mauricio Aug 26 '15 at 01:48
  • I think using GCM is a very simple approach. The messages are light in size too. Everyday apps use it. For example a chat app could send a push message every time a message is sent to the user. If you want to send something large, you could notify the client (maybe with a url?) so it requests the content to the server – bryant1410 Aug 26 '15 at 01:49
  • Even short messages have delays – Melvin Mauricio Aug 26 '15 at 01:50
  • @MelvinMauricio delays? It's pretty fast. Using the sender in the page http://stackoverflow.com/a/22169411/1165181 and an emulator drives the messages almost instantly – bryant1410 Aug 26 '15 at 01:51
  • yeah sometimes fast.. and sometimes slow.. i got a delay of notification for about 20 minutes... – Melvin Mauricio Aug 26 '15 at 01:52
  • @MelvinMauricio but which use are we talking about? Chat applications use it and it's blazing fast. – bryant1410 Aug 26 '15 at 01:52
  • @MelvinMauricio I have never had such delay. Are you sure you had internet connection? – bryant1410 Aug 26 '15 at 01:52
  • yes im sure i had an internet connection. There are many threads about gcm being delayed on notifications. – Melvin Mauricio Aug 26 '15 at 01:54
  • ok. you could use another push messaging server, or host your own maybe – bryant1410 Aug 26 '15 at 01:56