473,385 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1183
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.biz/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.org> 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.org> 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.com <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
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...
3
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. ...
5
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,...
18
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.