473,770 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is it possible to avoid loading the script for each request

I do not know PHP, consider to write a CGI with this technology and
have the following question.

Is it possible to invoke a PHP script and let it endlessly wait for
requests from a website (a Java applet in my case) and serve the
requests when they arrive? I want to avoid loading the script for each
request.

In other words, can it function, in this sense, like a Java servlet?

Jun 1 '07 #1
14 2045
On Jun 1, 3:00 am, DavidNorep <avdavid.nore.. .@gmail.comwrot e:
I do not know PHP, consider to write a CGI with this technology and
have the following question.

Is it possible to invoke a PHP script and let it endlessly wait for
requests from a website (a Java applet in my case) and serve the
requests when they arrive? I want to avoid loading the script for each
request.

In other words, can it function, in this sense, like a Java servlet?
What is the specific reason that you want to avoid loading the script
for each request?

Jun 1 '07 #2
To save time, to be able to respond to more requests.

I have also another question which is probably general for every CGI,
no matter in which technology it is implemented.

Suppose that a CGI is running and another request arrives, i.e., it is
invoked by another visitor to the website; will another instance of
the CGI start running or will the second request wait until the
running CGI finishes its work or is there a way to control this
behaviour.

Jun 1 '07 #3
Tom

"DavidNorep " <av************ *@gmail.comwrot e in message
news:11******** **************@ q75g2000hsh.goo glegroups.com.. .
To save time, to be able to respond to more requests.

I have also another question which is probably general for every CGI,
no matter in which technology it is implemented.

Suppose that a CGI is running and another request arrives, i.e., it is
invoked by another visitor to the website; will another instance of
the CGI start running or will the second request wait until the
running CGI finishes its work or is there a way to control this
behaviour.
I think programs like Apache are used to handling multiple requests at one
time. In a multi-user environment though you need to account for multiple
people making changes at the same time and the potential conflict with
people changing the same thing at the same time.

Tom
--
Newsguy.com - Unlimited Accounts
Now with 32 concurrent connections
Jun 1 '07 #4
On Jun 1, 2:01 pm, DavidNorep <avdavid.nore.. .@gmail.comwrot e:
To save time, to be able to respond to more requests.

I have also another question which is probably general for every CGI,
no matter in which technology it is implemented.

Suppose that a CGI is running and another request arrives, i.e., it is
invoked by another visitor to the website; will another instance of
the CGI start running or will the second request wait until the
running CGI finishes its work or is there a way to control this
behaviour.
Read this article, particularly Tip #5:

<http://www.ibm.com/developerworks/li...-code/?ca=dgr-
FClnxw01linuxco detips>

Jun 1 '07 #5
NC
On Jun 1, 12:00 am, DavidNorep <avdavid.nore.. .@gmail.comwrot e:
>
I do not know PHP, consider to write a CGI with this technology and
have the following question.

Is it possible to invoke a PHP script and let it endlessly wait for
requests from a website (a Java applet in my case) and serve the
requests when they arrive? I want to avoid loading the script for
each request.
No. But you don't have to configure your PHP setup as CGI;
configuring
it as an Apache module with an accelerator will do pretty much what
you
want; at the first call, the script will be compiled into bytecode
and
the bytecode will be cached, so beginning with the second call, the
script will not be loaded; cached bytecode will be used instead.
In other words, can it function, in this sense, like a Java servlet?
PHP is not Java. If you want something to function like a Java
servlet,
you should implement it as a Java servlet.

Cheers,
NC

Jun 2 '07 #6
NC
On Jun 1, 11:01 am, DavidNorep <avdavid.nore.. .@gmail.comwrot e:
>
I have also another question which is probably general for every
CGI, no matter in which technology it is implemented.
Nope; it's highly specific to the OS and HTTP server.
Suppose that a CGI is running and another request arrives, i.e.,
it is invoked by another visitor to the website; will another
instance of the CGI start running or will the second request wait
until the running CGI finishes its work
If the second request arrives and the HTTP server has enough
resources remaining to serve a response, it will. If the second
request arrives and the HTTP server does not have enough resources
remaining to serve a response, the second client will wait as
long as it is configured to do, then time out.
is there a way to control this behaviour.
Yes, but you have to code for it. Every instance of the script
must start by checking if it is the only one running (there are
many ways to get this done). If it is, it should keep running;
if it isn't, it should issue a "Location:" header to redirect
the client to itself.

Cheers,
NC

Jun 2 '07 #7
DavidNorep wrote:
I do not know PHP, consider to write a CGI with this technology and
have the following question.

Is it possible to invoke a PHP script and let it endlessly wait for
requests from a website (a Java applet in my case) and serve the
requests when they arrive? I want to avoid loading the script for each
request.
Yes, but only for output. I done web chat with this technology (I
call it endless connection) long time ago, before AJAX era. It was PHP
script on server-side and javascript on client-side. You need
set_time_limit( ) to prevent timeout on server so you can't do it in safe
mode. And you need to send periodically something to prevent timeout on
client. Request sent to additional short script who put it to database
or another place. Main script in endless loop checks for new requests,
process it and sends result back to client.
Now here is no reasons to do such things.
Jun 2 '07 #8

"Alexey Kulentsov" <cr*******@crim aniak.comschree f in bericht
news:46******** *************** @news.sunsite.d k...
DavidNorep wrote:
>I do not know PHP, consider to write a CGI with this technology and
have the following question.

Is it possible to invoke a PHP script and let it endlessly wait for
requests from a website (a Java applet in my case) and serve the
requests when they arrive? I want to avoid loading the script for each
request.
Yes, but only for output. I done web chat with this technology (I call
it endless connection) long time ago, before AJAX era. It was PHP script
on server-side and javascript on client-side. You need set_time_limit( ) to
prevent timeout on server so you can't do it in safe mode. And you need to
send periodically something to prevent timeout on client. Request sent to
additional short script who put it to database or another place. Main
script in endless loop checks for new requests, process it and sends
result back to client.
Now here is no reasons to do such things.
Correct me if I'm wrong here, but I thought there was some sort of solution
for this, using sockets. Or is this perhaps what you are refering to
already?

I once ran a very small test with socket connections as a command line
script. My goal was to write a little http chat app. I didn't follow up on
that anymore. But I had the feeling though that this little script could
easily be ported to some webserver environment. Probably not too a stressful
environment, but still.

@ DavidNorep: you mentioned the use of a JAVA applet. I don't know much
about JAVA but I assume JAVA has some socket interfaces itself too, no? This
could rule out client timeouts I think.

Also, I vaguely recall the script didn't need to loop, it would just
listened to a socket, and started doing things as soon as it got input on
the socket. I'll have look around to see if I can find the script.

In the meanwhile do a search for sockets. That should give you some
direction.
Jun 3 '07 #9

"amygdala" <no*****@norepl y.comschreef in bericht
news:46******** *************** @news.kpnplanet .nl...
>
"Alexey Kulentsov" <cr*******@crim aniak.comschree f in bericht
news:46******** *************** @news.sunsite.d k...
>DavidNorep wrote:
>>I do not know PHP, consider to write a CGI with this technology and
have the following question.

Is it possible to invoke a PHP script and let it endlessly wait for
requests from a website (a Java applet in my case) and serve the
requests when they arrive? I want to avoid loading the script for each
request.
Yes, but only for output. I done web chat with this technology (I call
it endless connection) long time ago, before AJAX era. It was PHP script
on server-side and javascript on client-side. You need set_time_limit( )
to prevent timeout on server so you can't do it in safe mode. And you
need to send periodically something to prevent timeout on client. Request
sent to additional short script who put it to database or another place.
Main script in endless loop checks for new requests, process it and sends
result back to client.
Now here is no reasons to do such things.

Correct me if I'm wrong here, but I thought there was some sort of
solution for this, using sockets. Or is this perhaps what you are refering
to already?

I once ran a very small test with socket connections as a command line
script. My goal was to write a little http chat app. I didn't follow up on
that anymore. But I had the feeling though that this little script could
easily be ported to some webserver environment. Probably not too a
stressful environment, but still.

@ DavidNorep: you mentioned the use of a JAVA applet. I don't know much
about JAVA but I assume JAVA has some socket interfaces itself too, no?
This could rule out client timeouts I think.

Also, I vaguely recall the script didn't need to loop, it would just
listened to a socket, and started doing things as soon as it got input on
the socket. I'll have look around to see if I can find the script.
Forget what I said about not having to loop. It *did* need to loop. I found
the core of the script I used in the PHP manual under Socket Functions. I
remember again.

HTH
Jun 3 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
1794
by: comp.lang.php | last post by:
I've heard numerous and varied commentaries here and on other fora regarding PHP and the concept of threads. Coming from a Java background I understand how threads benefit to prevent collisions, all the while carefully written to avoid "race conditions" while a web application is being utilized in a multi-user environment. However, are there examples in PHP alone where this same technology is possible? I am faced with having to deal...
11
8756
by: Jim | last post by:
Hi, I keep getting form results emailed to me that would indicate a form from my web site is getting submitted with all fields blank or empty, but my code should preventing users from proceeding if they left any field blank. My guess is that someone is trying to hack the site using the form to gain entry or run commands -- I don't really know since I'm not a hacker. I just know that forms are often susceptible to these kinds of...
6
1890
by: S P Arif Sahari Wibowo | last post by:
Hi! I am thinking to have a client-side script doing processing on file downloading, basically the script will process a downloaded file from the server before it received by the user. For example, the weboage will have a link to download file A, but the one stored in the server is not exactly file A, but some transformation of it. If the user click the link, it activate the script which will actually load the file from the server,...
4
3747
by: Adrian MacNair | last post by:
Hi, I created an image gallery which displays 63 images in a slideshow. The problem is that the show was slow because each image loaded one at a time during the show. No problem right? I just did a preload script. But then the user has to sit for 5 minutes waiting for 63 images to download! My images are about 640x480 and average 100kb. Is this too much for one page to load? Should I load my slideshow into differerent windows? If so,...
5
12238
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. The ID is a member of the keys array. I then create a DataView dv over the table, and sort it by Display and ID column (in case of duplicate Display). I then set my DataGrid.DataSource = dv; I then load the datatable with my rows, and this is...
8
1909
by: Daniel | last post by:
Hi, Does anyone know if it is possible to put an aspx page inside of another? OR run an aspx page and capture the output as a string and then write this out to a page.... So for example say you have a page that takes an id number as a query string and displays different things based on that id number. If you were able to loop through running the aspx pages with id=100, id=200,
6
2776
by: Venkatesh | last post by:
Hello All, I have couple of doubts regarding the concept of on-demand javascript loading using javascript code. I could see on the net different techniques for achieving this - techniques like: 1. document.write("<script src= language='JavaScript'></script>); 2. sc = document.createElement("<script>"); sc.setAttribute("src", ); and append this to the head
0
3138
by: VeeraLakshmi | last post by:
I am doing a project for internet control using Java,PHP and MySql.All sites should go through the proxy server only.We are giving access rights as allow or deny to the sites.If we type the url,first it will ask for authentication.After giving username and password,the authentication will be confirmed and if the site has access right as allow,the website will open else a page will be displayed.There we can send request mail to the...
1
2702
by: dtown22 | last post by:
I am trying to make a copy of all the files involved in a web request from a specific website (i.e. you enter groups.google.com, and hit enter once and then basically make a copy of all the files involved in loading that webpage). At first I figured that I could do everything programmtically, (i.e. open groups.google.com in my c# app, and them loop through all the hrefs and grab them one by one), but I would like to be able to write an...
0
9453
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10254
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10099
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8929
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7451
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.