473,756 Members | 5,156 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Server push

Hi all,
I have developed a PHP-based website where a "planner" user can make
up schedules of activities to be performed, storing them into MySQL
tables. Afterwards, other "watcher" users can connect to the website
and retrieve closest task due time, and keep retrieving next task
after each one has been performed.
The problem arises if the planner asynchronously changes the schedule,
e.g. deleting the task "watcher" users consider to be the next one, or
inserting a closer one. How would watchers know, without a cyclic
check on MySQL schedule table about task validity? I would need a sort
of asynchronous server-pushing tecnhique towards watcher's browser
when any schedule modification occurs.
Would you say this could be done with PHP alone?

Thanks a lot in advance

Michelle
Jul 17 '05 #1
8 6711
Michele wrote:
Hi all,
I have developed a PHP-based website where a "planner" user can make
up schedules of activities to be performed, storing them into MySQL
tables. Afterwards, other "watcher" users can connect to the website
and retrieve closest task due time, and keep retrieving next task
after each one has been performed.
The problem arises if the planner asynchronously changes the schedule,
e.g. deleting the task "watcher" users consider to be the next one, or
inserting a closer one. How would watchers know, without a cyclic
check on MySQL schedule table about task validity? I would need a sort
of asynchronous server-pushing tecnhique towards watcher's browser
when any schedule modification occurs.
Would you say this could be done with PHP alone?

Thanks a lot in advance

Michelle


Hi Michelle,

My first response would be: "Let the planners think before they shedule."
That would save you a lot of trouble, wouldn't it?
Anyway, this is the real world.

No such thing as real serverpush with PHP to my knowledge, but if your
browser is open during the task of your 'watcher-users', you can let the
browserwindow periodically check the server and ask if the task is still
valid.
If this is what you call "cyclic check on MySQL schedule table" then I think
you cannot work around it.

This can easily be accomplished by using a frameset, and make one frame
invissible. In that frame you call a php-script that checks the validity of
the task, and when it is not valid, you can return code that for example
creates a javascript allert.
I hope this helps. :-)

Good luck and regards,
Erwin Moller
Jul 17 '05 #2
Hi Erwin,
I know the "hidden" periodic check on the server would be the easiest
solution. The hard part would be the tuning of periodicity interval.
Actually, I've been thinking about a different solution, exploiting
PHP socket functions: I would have a server socket open in the
"hidden" frame, waiting for update alerts. Any time a change in the
schedule is performed by planner users, a PHP script could connect to
the socket, triggering a refresh of the task list page by the watcher
user.
Although this could save the day, it sounds sort of a dirty trick to
me. I would seek a cleaner solution first (if available).

Michelle

Erwin Moller <si************ *************** *************** @spamyourself.c om> wrote in message news:<3f******* *************** *@news.xs4all.n l>...
Michele wrote:
Hi all,
I have developed a PHP-based website where a "planner" user can make
up schedules of activities to be performed, storing them into MySQL
tables. Afterwards, other "watcher" users can connect to the website
and retrieve closest task due time, and keep retrieving next task
after each one has been performed.
The problem arises if the planner asynchronously changes the schedule,
e.g. deleting the task "watcher" users consider to be the next one, or
inserting a closer one. How would watchers know, without a cyclic
check on MySQL schedule table about task validity? I would need a sort
of asynchronous server-pushing tecnhique towards watcher's browser
when any schedule modification occurs.
Would you say this could be done with PHP alone?

Thanks a lot in advance

Michelle


Hi Michelle,

My first response would be: "Let the planners think before they shedule."
That would save you a lot of trouble, wouldn't it?
Anyway, this is the real world.

No such thing as real serverpush with PHP to my knowledge, but if your
browser is open during the task of your 'watcher-users', you can let the
browserwindow periodically check the server and ask if the task is still
valid.
If this is what you call "cyclic check on MySQL schedule table" then I think
you cannot work around it.

This can easily be accomplished by using a frameset, and make one frame
invissible. In that frame you call a php-script that checks the validity of
the task, and when it is not valid, you can return code that for example
creates a javascript allert.
I hope this helps. :-)

Good luck and regards,
Erwin Moller

Jul 17 '05 #3
Michele wrote:

Hi Michele,
Hi Erwin,
I know the "hidden" periodic check on the server would be the easiest
solution. The hard part would be the tuning of periodicity interval.
Why? You could do it every 30 seconds or so?
But of course I don't know all your requirements, so .... :-)
Actually, I've been thinking about a different solution, exploiting
PHP socket functions: I would have a server socket open in the
"hidden" frame, waiting for update alerts. Any time a change in the
schedule is performed by planner users, a PHP script could connect to
the socket, triggering a refresh of the task list page by the watcher
user.
Please be aware of the fact that many people have only a few port to open
because of firewalls.
And browsers have time-outs, so if you let the frame 'wait' for the socket
to respond, I wouldn't be suprised to find it closed soon.
Although this could save the day, it sounds sort of a dirty trick to
me. I would seek a cleaner solution first (if available).

Keep me (us) informed of your solution!

Regards,
Erwin Moller
Michelle

Erwin Moller
<si************ *************** *************** @spamyourself.c om> wrote in
message news:<3f******* *************** *@news.xs4all.n l>...
Michele wrote:
> Hi all,
> I have developed a PHP-based website where a "planner" user can make
> up schedules of activities to be performed, storing them into MySQL
> tables. Afterwards, other "watcher" users can connect to the website
> and retrieve closest task due time, and keep retrieving next task
> after each one has been performed.
> The problem arises if the planner asynchronously changes the schedule,
> e.g. deleting the task "watcher" users consider to be the next one, or
> inserting a closer one. How would watchers know, without a cyclic
> check on MySQL schedule table about task validity? I would need a sort
> of asynchronous server-pushing tecnhique towards watcher's browser
> when any schedule modification occurs.
> Would you say this could be done with PHP alone?
>
> Thanks a lot in advance
>
> Michelle


Jul 17 '05 #4
Michele wrote:
Hi all,
I have developed a PHP-based website where a "planner" user can make
up schedules of activities to be performed, storing them into MySQL
tables. Afterwards, other "watcher" users can connect to the website
and retrieve closest task due time, and keep retrieving next task
after each one has been performed.
The problem arises if the planner asynchronously changes the schedule,
e.g. deleting the task "watcher" users consider to be the next one, or
inserting a closer one. How would watchers know, without a cyclic
check on MySQL schedule table about task validity? I would need a sort
of asynchronous server-pushing tecnhique towards watcher's browser
when any schedule modification occurs.
Would you say this could be done with PHP alone?


I've looked into this extensively as I really could do with something of
the sort. My findings were:

1. server push is exactly what the doctor ordered but Netscape
(Mozilla?) only.

2. you can arrange polling through some combination of meta-refresh or
javascript. This can leave the main displayed page unaffected with
iframes or a frameset. I often do this by creating a frameset with a
'connection bar' across the bottom of the document. This is refreshed
periodically and any delivered instance may contain javascript to modify
or reload the main page. As you say though, the timing of this is an
issue. I sometimes have to defer links and submits through a reload of
the connection bar to ensure that the requested action is still valid.

3. if you really want to reproduce server push you will need an activex
or java applet which leaves open a socket to your server. However quite
a lot of firewalls and proxies will stamp all over this and time the
connection out.

If anyone has any better ideas then I am all ears

Kevin Thorpe
Head of IT
Purchasing Index (UK) Ltd

Jul 17 '05 #5
well, firewalls or proxies are not an issue here, since the I'm
working within my company Intranet, so I should have any port
available.
On the other hand, I admit my ignorance about browser timeout. I
didn't know about this other aspect. What's the default value? and (of
course) is there any way to change it? After all, this timeout could
affect my "hidden" refresh as well if I set my refresh rate too large,
coudn't it?

Michelle

Kevin Thorpe <ke***@pricetra k.com> wrote in message news:<3f******* *************** *@news.easynet. co.uk>...

I've looked into this extensively as I really could do with something of
the sort. My findings were:

1. server push is exactly what the doctor ordered but Netscape
(Mozilla?) only.

2. you can arrange polling through some combination of meta-refresh or
javascript. This can leave the main displayed page unaffected with
iframes or a frameset. I often do this by creating a frameset with a
'connection bar' across the bottom of the document. This is refreshed
periodically and any delivered instance may contain javascript to modify
or reload the main page. As you say though, the timing of this is an
issue. I sometimes have to defer links and submits through a reload of
the connection bar to ensure that the requested action is still valid.

3. if you really want to reproduce server push you will need an activex
or java applet which leaves open a socket to your server. However quite
a lot of firewalls and proxies will stamp all over this and time the
connection out.

If anyone has any better ideas then I am all ears

Kevin Thorpe
Head of IT
Purchasing Index (UK) Ltd

Jul 17 '05 #6
Michele wrote:
well, firewalls or proxies are not an issue here, since the I'm
working within my company Intranet, so I should have any port
available.
On the other hand, I admit my ignorance about browser timeout. I
didn't know about this other aspect. What's the default value? and (of
course) is there any way to change it? After all, this timeout could
affect my "hidden" refresh as well if I set my refresh rate too large,
coudn't it?


I've looked for settings to affect browser timeouts, even delving
through the registry and cannot find any (for IE). I do know that it
appears to give up after a while. It's quite a long delay anyway.

In reality you will be polling the server at fairly regular intervals
and the server side query and reply should be very quick and short. I
usually have the main page include a timestamp which is passed in the
url to the 'check changed' frame. The return value is either a blank
document or a single line of javascript to refresh the parent/opener.

Your real problem here is stopping someone choosing a task which has
been taken after the last page load. I'v got an idea but I've got to go
now. I'll give you further information tomorrow.
Jul 17 '05 #7
Sorry about yesterday, I was really unwell. Anyway I promised to explain
further on how to sort your problem out.

Use a frameset.
+---------------------------------------------+
| <main> main page with list of tasks |
| |
| |
| |
| |
| |
+---------------------------------------------+
| <query> single row to perform queries in |
+---------------------------------------------+

The main page should display the current table of tasks to select from.
These links should call javascript to ask the query page to select a task:
<script language=javasc ript>
function choosetask(task num) {
window.parent.q uery.location.h ref='query.php? choosetask='+ta sknum;
}
</script>
<a href='' onClick='choose task(<?=$tasknu m?>); return false;'>Choose</a>

The query page should do two things. Firstly it should refresh itself
periodically to see if the database has changed. If it has then it
should refresh the main page. Secondly, if it has been asked to choose a
task then it should check if that task is still available.

<?php # get the last update time
$result = mysql_query("SE LECT lastupdate FROM STATUS");
$row = mysql_fetch_ass oc($result);
$lastupdate = $row['lastupdate'];
if ($lastupdate > $_REQUEST['lastupdate']) {
$reload = true;
}
?>
<html>
<head>
<meta http-equiv=refresh content="20;
url='http://www.server.com/query.php?<?=$l astupdate?>'">
</head>
<body>
<?php if ($_REQUEST['choosetask']) {
# we've been asked to choose a task
$result = mysql_query("UP DATE TASKS SET status='busy' ".
"WHERE ID=$_REQUEST[choosetask] ".
"AND status='free' ");
if (mysql_num_rows () == 1) {
# update worked, you have the task
$result = mysql_query("UP DATE STATUS SET lastupdate=NOW( )");
echo "<script language=javasc ript>\n".
"alert('You have the task');\n".
"window.parent. main.location.r eload();\n".
"</script>\n";
} else {
# failed - task missing or taken
echo "<script language=javasc ript>\n".
"alert('Sor ry, that task has already been taken');\n".
"window.parent. main.location.r eload();\n".
"</script>\n";
}
} else {
# just a refresh - check if database has changed
if ($reload) {
echo "<script language=javasc ript>\n".
"window.parent. main.location.r eload();\n".
"</script>\n";
}
} ?>
</body>
</html>

This way you get a check when you try and select a task to avoid double
selecting. Of course you will occasionally get a 'sorry' on selecting a
task, but this seems the easiest way to do things.

I hope this helps.

Jul 17 '05 #8
Yes, I was thinking about something similar myself too:
- Whenever the "watcher" user first starts, "main" frame queries the
server for the closest task in schedule, and then implements a
javascript-based countdown for that task itself.
- The "hidden" frame refreshes itself every 20-30 seconds (should be
enough to avoid browser timeout, I hope), asking the server about
validity of its current closest task. If task is not valid anymore,
this frame orders a refresh of "main" frame, which queries the task
schedule again and updates the countdown.
- If a "planner" user changes the schedule, the watcher will know as
soon as next "hidden" frame refresh occurs; "planner" user will not be
allowed to delete a task if it is "too" close (configurable), just to
make sure a task is not deleted when it is about to be performed (the
whole environment is synchronized though NTP).

So, I seem to surrender to periodic page refresh, if no other reliable
solution exists. Too bad...
Thanks again for your suggestions

Michelle

From: Kevin Thorpe [mailto:ke***@pr icetrak.com]
Sent: venerdì 31 ottobre 2003 12.06

To: Betti Michele
Subject: Re: Server push

Sorry about yesterday, I was really unwell. Anyway I promised to explain further on how to sort your problem out.
Use a frameset.
+---------------------------------------------+
| <main> main page with list of tasks |
| |
| |
| |
| |
| |
+---------------------------------------------+
| <query> single row to perform queries in |
+---------------------------------------------+

The main page should display the current table of tasks to select from.
These links should call javascript to ask the query page to select a task:
<script language=javasc ript>
function choosetask(task num) {
window.parent.q uery.location.h ref='query.php? choosetask='+ta sknum;
}
</script>
<a href='' onClick='choose task(<?=$tasknu m?>); return false;'>Choose</a>

The query page should do two things. Firstly it should refresh itself
periodically to see if the database has changed. If it has then it
should refresh the main page. Secondly, if it has been asked to choose a
task then it should check if that task is still available.

<?php # get the last update time
$result = mysql_query("SE LECT lastupdate FROM STATUS");
$row = mysql_fetch_ass oc($result);
$lastupdate = $row['lastupdate'];
if ($lastupdate > $_REQUEST['lastupdate']) {
$reload = true;
}
?>
<html>
<head>
<meta http-equiv=refresh content="20;
url='http://www.server.com/query.php?<?=$l astupdate?>'">
</head>
<body>
<?php if ($_REQUEST['choosetask']) {
# we've been asked to choose a task
$result = mysql_query("UP DATE TASKS SET status='busy' ".
"WHERE ID=$_REQUEST[choosetask] ".
"AND status='free' ");
if (mysql_num_rows () == 1) {
# update worked, you have the task
$result = mysql_query("UP DATE STATUS SET lastupdate=NOW( )");
echo "<script language=javasc ript>\n".
"alert('You have the task');\n".
"window.parent. main.location.r eload();\n".
"</script>\n";
} else {
# failed - task missing or taken
echo "<script language=javasc ript>\n".
"alert('Sor ry, that task has already been taken');\n".
"window.parent. main.location.r eload();\n".
"</script>\n";
}
} else {
# just a refresh - check if database has changed
if ($reload) {
echo "<script language=javasc ript>\n".
"window.parent. main.location.r eload();\n".
"</script>\n";
}
} ?>
</body>
</html>

This way you get a check when you try and select a task to avoid double
selecting. Of course you will occasionally get a 'sorry' on selecting a
task, but this seems the easiest way to do things.

I hope this helps.

Jul 17 '05 #9

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

Similar topics

3
4306
by: John Bradbury | last post by:
I want to send updates from a long running cgi. I have tried copying perl examples of server push and can not get them to work. Does anyone have an idiot proof example of a working server push or sending output in chunks in Python? Thanks John Bradbury
7
5114
by: DW | last post by:
Hi, Here is my question. I want to push security prices to the desktop from the server. Whenever there is a new price in the database, the server notifies the client. How can this be done in the following situations using MS .NET Winforms on the desktop: 1. Using .NET Web Services on server 2. Using Java Web Services on server
3
2530
by: Ben Kim | last post by:
Hello all, We are interested in having a server push data down to the client on a periodic basis (IE data change). This data would need to be pushed into a grid control. We do not want to "update" the page or refresh every n seconds. After reviewing 'Server Push Techology' it appears Microsoft abandoned the technology with IE 4. I may be wrong. If they didn't abandon it did they replace it with a comparable solution?
6
1519
by: Martin Holmgaard | last post by:
I have written the following function to be used for flood filling in a bitmap. The function works fine on Windows XP Prof and Windows 2000 server, but on Windows 2003 server it return a stack overflow if the function runs recursive more than 5495 times. Does anyone know a solution on the problem eg. how to extend the stack size on Windows 2003, or better a non-recursive function for flood filling an image ? Function fncFloodFill(ByVal...
4
3158
by: batista | last post by:
Hello All, my prob. is that i have a web server, and i want it to send fresh data,whenver it is available(from sum other source), to a webpage. Now i used refresh, but i want to use an alternative. I heard that refresh is called pull scheme, and the one i'm looking for is caled push scheme.
1
1621
by: Rodney | last post by:
I want to notify browser of every time my server side event fires w/o creating some sort of timer on client. Basically, can server notify client w/o client initiating contact? Again, thx for any information you can provide.
0
2811
by: Crisco www.misericordia.com.br | last post by:
Hi I m working on WEBRADIO Software. im using Windows media encoder 9 SDK on Windows 2003 server using VB.NET. My current scenario is my soundcard . My application will push my server the live audio on specific port. I am using Windows media encoder sdk sample (entire code), currently i
5
2469
by: Mark Goldin | last post by:
Can I create a push server using ASP technology? Thanks
0
918
by: davy zhang | last post by:
import asyncore, asynchat import os, socket, string PORT = 8000 class HTTPChannel(asynchat.async_chat): def __init__(self, server, sock, addr): asynchat.async_chat.__init__(self, sock) self.set_terminator("\r\n")
0
9462
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9287
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
10046
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
9886
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
9857
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
9722
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
6542
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();...
1
3817
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
3369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.