Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8640961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:24:18+00:00 2026-06-12T11:24:18+00:00

Is there a way to keep a connection open between an Android app and

  • 0

Is there a way to keep a connection open between an Android app and a PHP script, so if there are any updates, the PHP script can push notifications out to the android app, rather than the app having to make a HTTP request every X minutes to ask for any updates?

I know this isn’t possible via Ajax without installing things on the server side to enable them, but I’m wondering if its any different on Android.

E.g if I did the following on the PHP side:

<?
set_time_limit(0);
while (true)
{
   $updates = $updater->find();
   if ($updates)
      ob_flush( $updates->getAsJSON() );
   sleep(60);
}
?>

Will something like this work to keep a connection open and push out updates to the android app?

The server is running Apache and PHP 5.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:24:19+00:00Added an answer on June 12, 2026 at 11:24 am

    Your code will work in theory, but will also cause unneeded CPU usage, because you look for updates every minute, and, depending on $updater implementation, this may waste CPU, memory and IO. If you want an event-driven communication not to waste resources, you need an event-based backend – and there are plenty of them out there, but none in PHP, and that’s because it’s a PHP limit. There’s no way, in a PHP script, to go multithread and wait(), so basically you can’t implement the Observer pattern, and this in turn prevents them from writing event-driven libraries in PHP.

    I don’t think you want to do this. Unless you can without any doubt count users on your fingers, this task cannot be handled by PHP. It’s not an issue with the webserver, it’s an issue with PHP itself. Each PHP request (either via mod_php, fcgi, php-fpm) is handled with a new PHP process. This makes it impossible to scale, and that’s why you need to install use other server-side technologies to implement long polling.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to keep this simple JQuery animation from flashing? http://jsfiddle.net/v3DVf/6/
Is there a way to keep any DLLs needed for my Visual C# program
Is there any way to keep track the state of a UIButton whether it
I am wondering if there is any way to keep the indentation with jinja
Is there a straight forward way to keep track of game time in Android
Is there a way to keep a HTTP connection alive with JavaScript?
Is there a way to keep a window inactive looking, even if it contains
Is there a way to keep MSMQ outgoing queues on a server in state
Is there a good way to keep keys from conflicting when using the Microsoft
Is there a good way to keep consistency in the $_GET For example if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.