473,785 Members | 2,185 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
14 2046
amygdala wrote:
"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.
Good thing you didn't follow up with this though. A socket-attached
script is much different than a web-based one.
@ 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.
Yes, java has socket interfaces. But it doesn't rule out client timeouts.
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.

As I said - socket interfaces are much different that web-based ones.
For one thing - sockets typically stay open as long as the chat (or
whatever) session is active. Sockets used for HTTP are closed at the
end of each page.

A BIG difference.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 3 '07 #11

"Jerry Stuckle" <js*******@attg lobal.netschree f in bericht
news:Yr******** *************** *******@comcast .com...
amygdala wrote:
>"Alexey Kulentsov" <cr*******@crim aniak.comschree f in bericht
news:46******* *************** *@news.sunsite. dk...
>>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.

Good thing you didn't follow up with this though. A socket-attached
script is much different than a web-based one.
>@ 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.

Yes, java has socket interfaces. But it doesn't rule out client timeouts.
>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.

As I said - socket interfaces are much different that web-based ones. For
one thing - sockets typically stay open as long as the chat (or whatever)
session is active. Sockets used for HTTP are closed at the end of each
page.

A BIG difference.
Hmm, I probably didn't express myself good enough then. Or perhaps I'm
missing essential knowledge here. But the point I was hoping to get accross
was, that perhaps because JAVA can handle socket connections it wouldn't
have to be an HTTP socket that the applet connects to. Rather it could
maintain a statefull connection on some port? Does that make any sense? Or
am I talking complete rubbish here? Could very well be. ;-) Cause my
networking knowledge is very poor.
Jun 3 '07 #12
amygdala wrote:
"Jerry Stuckle" <js*******@attg lobal.netschree f in bericht
news:Yr******** *************** *******@comcast .com...
>amygdala wrote:
>>"Alexey Kulentsov" <cr*******@crim aniak.comschree f in bericht
news:46****** *************** **@news.sunsite .dk...
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.
Good thing you didn't follow up with this though. A socket-attached
script is much different than a web-based one.
>>@ 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.
Yes, java has socket interfaces. But it doesn't rule out client timeouts.
>>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.
As I said - socket interfaces are much different that web-based ones. For
one thing - sockets typically stay open as long as the chat (or whatever)
session is active. Sockets used for HTTP are closed at the end of each
page.

A BIG difference.

Hmm, I probably didn't express myself good enough then. Or perhaps I'm
missing essential knowledge here. But the point I was hoping to get accross
was, that perhaps because JAVA can handle socket connections it wouldn't
have to be an HTTP socket that the applet connects to. Rather it could
maintain a statefull connection on some port? Does that make any sense? Or
am I talking complete rubbish here? Could very well be. ;-) Cause my
networking knowledge is very poor.

You made a comment: "My goal was to write a little http chat app."

Is this an http app? If so, the client will get timeouts - it can't be
helped. It's part of the protocol (and built into the browsers), no
matter what port you're running on (and no, http is not restricted to
port 80, although that's the most common one). But in general you'll
want some kind of webserver to help with the connections and processing.

If it's not a http app, you have more control over timeouts, although
they can still occur. But you won't be able to use browsers.

You can set up connections on many ports. But there's a lot more to
handling network connections than just opening a port - especially if
you're going to have multiple people connecting. And that's true in any
language.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 3 '07 #13

"Jerry Stuckle" <js*******@attg lobal.netschree f in bericht
news:Zb******** *************** *******@comcast .com...
amygdala wrote:
>"Jerry Stuckle" <js*******@attg lobal.netschree f in bericht
news:Yr******* *************** ********@comcas t.com...
>>amygdala wrote:
"Alexey Kulentsov" <cr*******@crim aniak.comschree f in bericht
news:46***** *************** ***@news.sunsit e.dk...
DavidNore p 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_li mit() 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.

Good thing you didn't follow up with this though. A socket-attached
script is much different than a web-based one.

@ 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.

Yes, java has socket interfaces. But it doesn't rule out client
timeouts.

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.
As I said - socket interfaces are much different that web-based ones.
For one thing - sockets typically stay open as long as the chat (or
whatever) session is active. Sockets used for HTTP are closed at the
end of each page.

A BIG difference.

Hmm, I probably didn't express myself good enough then. Or perhaps I'm
missing essential knowledge here. But the point I was hoping to get
accross was, that perhaps because JAVA can handle socket connections it
wouldn't have to be an HTTP socket that the applet connects to. Rather it
could maintain a statefull connection on some port? Does that make any
sense? Or am I talking complete rubbish here? Could very well be. ;-)
Cause my networking knowledge is very poor.

You made a comment: "My goal was to write a little http chat app."
Yes you are right, my bad, slip of the tongue. I was implying a chat app
which would be build in a website (hence the 'incorrect' http comment). I
understand this is not correct terminology. I on occasion mix up
terminology. I tend to think people see through that and get the big picture
I'm getting after. But I need to watch my terminology better I guess. Mea
culpa ;-)
Is this an http app? If so, the client will get timeouts - it can't be
helped. It's part of the protocol (and built into the browsers), no
matter what port you're running on (and no, http is not restricted to port
80, although that's the most common one). But in general you'll want some
kind of webserver to help with the connections and processing.

If it's not a http app, you have more control over timeouts, although they
can still occur. But you won't be able to use browsers.

You can set up connections on many ports. But there's a lot more to
handling network connections than just opening a port - especially if
you're going to have multiple people connecting. And that's true in any
language.
I can easily imagine this to be true Jerry, but then, that's not what the OP
asked. The OP asked whether it was possible.
Jun 3 '07 #14
amygdala wrote:
"Jerry Stuckle" <js*******@attg lobal.netschree f in bericht
news:Zb******** *************** *******@comcast .com...
>amygdala wrote:
>>"Jerry Stuckle" <js*******@attg lobal.netschree f in bericht
news:Yr****** *************** *********@comca st.com...
amygdala wrote:
"Alexey Kulentsov" <cr*******@crim aniak.comschree f in bericht
news:46**** *************** ****@news.sunsi te.dk...
>DavidNor ep 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
>>request s from a website (a Java applet in my case) and serve the
>>request s 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_l imit() 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.
>
Good thing you didn't follow up with this though. A socket-attached
script is much different than a web-based one.

@ 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.
>
Yes, java has socket interfaces. But it doesn't rule out client
timeouts.

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 .
As I said - socket interfaces are much different that web-based ones.
For one thing - sockets typically stay open as long as the chat (or
whatever) session is active. Sockets used for HTTP are closed at the
end of each page.

A BIG difference.

Hmm, I probably didn't express myself good enough then. Or perhaps I'm
missing essential knowledge here. But the point I was hoping to get
accross was, that perhaps because JAVA can handle socket connections it
wouldn't have to be an HTTP socket that the applet connects to. Rather it
could maintain a statefull connection on some port? Does that make any
sense? Or am I talking complete rubbish here? Could very well be. ;-)
Cause my networking knowledge is very poor.
You made a comment: "My goal was to write a little http chat app."

Yes you are right, my bad, slip of the tongue. I was implying a chat app
which would be build in a website (hence the 'incorrect' http comment). I
understand this is not correct terminology. I on occasion mix up
terminology. I tend to think people see through that and get the big picture
I'm getting after. But I need to watch my terminology better I guess. Mea
culpa ;-)
>Is this an http app? If so, the client will get timeouts - it can't be
helped. It's part of the protocol (and built into the browsers), no
matter what port you're running on (and no, http is not restricted to port
80, although that's the most common one). But in general you'll want some
kind of webserver to help with the connections and processing.

If it's not a http app, you have more control over timeouts, although they
can still occur. But you won't be able to use browsers.

You can set up connections on many ports. But there's a lot more to
handling network connections than just opening a port - especially if
you're going to have multiple people connecting. And that's true in any
language.

I can easily imagine this to be true Jerry, but then, that's not what the OP
asked. The OP asked whether it was possible.

Yes, and there's a big difference between *possible* and *practical*.

It's possible for me to build a 747. All the technical details are
easily available. But it's not practical.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 3 '07 #15

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

Similar topics

14
1795
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
3748
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
12239
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
1911
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
3139
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
9484
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
10157
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...
0
9957
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8983
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...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
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
4055
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
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
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.