Reply to Re: Running php file as a background process

Your name:

Reply:


Posted by Jerry Stuckle on 11/06/07 13:44

Ravi wrote:
> Hi,
> Thanks for replying. Ya this is my own system. But if it listen any
> commands then the handler should execute the functions of a
> particular object. where object will be created when i start the
> process.
>
> The process is like this
>
> 1. user presses a start button.
> 2. Then i should create an object . For exg obj = new A(); where obj
> will have the user details.
> 3. then one program should run background to listen on a port.
> 4. When it got any response then it should manipulate the object user
> data.
> 5. In the meanwhile user can use the user interface through browser.
>
> If u got any solution plz send me it is very urgent.
>
>
>
> Regards,
> Ravindra.
>
>

Ravi,

You can do it in PHP, at least on Unix, but it's not going to be easy.

Probably the best way is with shared memory and semaphores.

First of all, you'll need to compile PHP with the --enable-sysvsem flag
to get the shared memory and ipc functions.

You can then create a shared memory segment and use semaphores to
serialize access to the shared memory, or use message queues to send
messages back and forth (or both). Start a process in the background to
handle the socket communications and communicate between it and your web
page.

But there are a lot of problems with this. First of all, HTTP is a
request/response protocol; the server can't just arbitrarily send
information to the browser. The browser has to request it. So if there
is a change in the object's data, this won't be reflected in the user's
browser until they refresh (or do something else). You can get around
this to a certain point with automatically refreshing the page (i.e.
meta refresh or javascript), but there will be a delay.

Also, web pages are transactional - that is, from the server side, the
page loads, executes, sends its data to the client and terminates. So
you need to keep track of your communications methods between pages.
You can use sessions to do this, but you won't be able to keep the
shared memory or message queue itself in the session - just the name.

Something like this isn't real difficult in C/C++ or Java (but it's not
easy, either). However, I really wonder if PHP is a good choice here.
I would think maybe a Java applet on the client and a Java program
running on the server would be better.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация