Socket.

3 views
Skip to first unread message

Jean-Christophe

unread,
Nov 29, 2010, 8:29:18 AM11/29/10
to
Hi,

I develop an http server using windows sockets,
and I need to implement this :

1: A browser sends a request to the server.

2: The server sends an html page to the browser.

3: When needed, the server sends a new html updated page to
the browser. This page should replace the preceding one.

Note that the page update is not triggered
by the browser but by the server itself.

First I tried to include this in the html page header:
<meta http-equiv="refresh" content="10; URL=http://server/">
it works but the refresh is not triggered by the server itself.

Then I tried this : after the server has sent
the very first html page it keeps the socket open
and when needed sends to the browser a JavaScript:
window.location.replace("http://server/");
and then closes the socket. The client sends back a request
to the server (as if the user had refreshed the browser's page)
It works but on one hand the server has to keep the socket open,
and on the other hand I guess that the browser could time-out.

Is there an effective way to update a
browser's html page from the server-side ?

TIA

David Schwartz

unread,
Dec 5, 2010, 11:31:16 PM12/5/10
to
On Nov 29, 5:29 am, Jean-Christophe <5...@free.fr> wrote:

> Is there an effective way to update a
> browser's html page from the server-side ?

Fundamentally, the server cannot connect to the client. So your two
choices are to have the client periodically ask the server if it needs
to do anything or you have to sustain a connection that was initiated
by the client.

DS

Jean-Christophe

unread,
Dec 8, 2010, 1:18:12 PM12/8/10
to
On Dec 6, 5:31 am, David Schwartz

|> Is there an effective way to update a
|> browser's html page from the server-side ?

> Fundamentally, the server cannot connect to the client. So your two
> choices are to have the client periodically ask the server if it needs
> to do anything or you have to sustain a connection that was initiated
> by the client.

Ok. However, I don't want many browsers sending periodic
requests to the server as there *could* be nothing to update;
most of the requests would be useless.
For now I'll keep my trick - it works pretty well.
Thanks Dave.

Reply all
Reply to author
Forward
0 new messages