473,698 Members | 2,635 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to send a query to the browser from time to time?

I am creating a chat application like Messenger for the web (using the
browser) and I'm wondering if there is a way to receive new messages from
time to time from the server other than refreshing the page each 5 sec.

If there were a way to have the server-side application send new messages
to the browser this would be awesome because it would save dramatically on
bandwidth. The application would consume bandwidth only when there are new
messages. There would be no communication client-server until people write
a new message.

Do you know if it's possible?

--
Thanks,

Admin.
Want to buy me a book? http://tinyurl.com/78xzb :)
Jul 21 '05 #1
9 1197
Short answer: Not using HTTP.

However, you can use something like AJAX to just load new data from
time to time and not the entire page.

Or you might be able to keep the connection alive and occationally send
stuff to the client using chunked transfer.

I'd go for the ajax route if you don't need to support old browsers.

Jul 21 '05 #2
not clear if you're asking about XMLHttpRequest

http://www.modernmethod.com/sajax/
http://nevow.com/Nevow2004Tutorial.html#livepage

or custom browser object:

http://wwwsearch.sourceforge.net/mechanize/

Jul 21 '05 #3
phr
Admin <me@privacy.net > writes:
If there were a way to have the server-side application send new
messages to the browser this would be awesome because it would save
dramatically on bandwidth. The application would consume bandwidth
only when there are new messages. There would be no communication
client-server until people write a new message.

Do you know if it's possible?


Some people have done stuff like that with multipart mime encodings
and chunked transfers. I've looked into it but I'm not sure of the
exact mechanism any more. It's kind of messy.

The other usual way is to open a tcp connection from a java applet.
I don't like that since it means you need java in your browser.

There's a chat app called arsc that you might look at:

http://manuel.kiessling.net/projects/software/arsc/

Warning, last time I looked at it, it had some security bugs.
Jul 21 '05 #4
On Tue, 19 Jul 2005 10:03:48 -0300, Simon Dahlbacka
<si************ *@gmail.com> wrote:
I'd go for the ajax route if you don't need to support old browsers.


I already use AJAX on several applications, but I don't want to use it in
this one because it would poll the server a lot and it may bring the
server down if there are many people using the chat application at the
same time (too many queries to the database).

--
Thanks,

Admin.
Want to buy me a book? http://tinyurl.com/78xzb :)
Jul 21 '05 #5
rewrite the server to bake a /lastmsg/ folder with the last message in
it. otherwise, my only suggestion is to use another protocol instead of
http.

Jul 21 '05 #6
Admin wrote:
I am creating a chat application like Messenger for the web (using the
browser) and I'm wondering if there is a way to receive new messages
from time to time from the server other than refreshing the page each 5
sec.


Here's a pretty basic example I wrote a while ago using Twisted:
<http://tw.ecritters.bi z/files/twistedchat.py> . The server keeps the
connection open and sends messages when they occur, with the side effect
of keeping the browser's page-loading indicator alive indefinitely.
Jul 21 '05 #7
"Simon Dahlbacka" <si************ *@gmail.com> writes:
Short answer: Not using HTTP.

However, you can use something like AJAX to just load new data from
time to time and not the entire page.


AJAX is overkill for this. If you just want to automatically refresh
the page automatically, you can use a meta refresh tag.

<mike
--
Mike Meyer <mw*@mired.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jul 21 '05 #8
On Wed, 20 Jul 2005 00:26:13 -0300, Mike Meyer <mw*@mired.or g> wrote:
AJAX is overkill for this. If you just want to automatically refresh
the page automatically, you can use a meta refresh tag.


Reloading the page automatically would be even worse because it would
spend a lot of bandwidth, it would reload all the page and graphics all
the time.

--
Thanks,

Admin.
Want to buy me a book? http://tinyurl.com/78xzb :)
Jul 21 '05 #9
On Tue, 19 Jul 2005 19:43:25 -0300, sp*****@gmail.c om <sp*****@gmail. com>
wrote:
otherwise, my only suggestion is to use another protocol instead of
http.


What do you suggest?
--
Thanks,

Admin.
Want to buy me a book? http://tinyurl.com/78xzb :)
Jul 21 '05 #10

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

Similar topics

11
12082
by: Google Mike | last post by:
I've got RH9 Linux with default PHP. Is there a way to send email on Linux to an Exchange Server from PHP and/or other tools when there is *NOT* SMTP access? Has anyone figured out a way to use PHP to get inside an OWA (Microsoft Outlook Web Access) website to send email that way? The reason I ask is because my corporate office is going to do away with our rogue SMTP server access and force everything through Exchange
3
2749
by: robboll | last post by:
Whenever I query my database using Enterprise Manager, the response time is about a second. When I access the same data via a Cold Fusion webpage, it takes about 15 seconds (or more) to resolve. I created an index for the fields involved in the query and updated statistics. It makes no difference. Is there anything else I should look at? The table is only about 3000 records. Any suggestions to speed up queries when using Cold Fusion?...
5
4849
by: zorhel | last post by:
Hi. My clients will be IE, Mozilla and Opera in a Windows and *nix OS. So, my web app need to, from a server, send messages to a specific client (browser), send messages for all clients, redirect a client to another page. In other way, a client will be able to send messages to another client, throw the server. These are the first funcionalities.
18
44652
by: A.M | last post by:
Hi, Is there any way to call a WSS web service method by using browser and see the XML result in browser as well? I have been told that there is query string syntax for calling webservices.
0
8683
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
8610
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
9170
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
9031
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
8902
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
7740
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
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
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
2339
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.