Re: PHP & open connections



Kimmo Laine wrote:
"Lenard Redwood" <freakingcrazy@xxxxxxxxx> wrote in message news:1159809523.767613.115970@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Jerry Stuckle wrote:

You can't. HTTP is a pull only protocol. You can use javascript on the
client to pull the info on a regular basis (i.e. every 30 seconds). But
you can't push the data out.

Exactly, actually each time user A writes a message and hits "Enter" it
is sent right away to the server. But how can this message be thrown
into the open connection that user B is using?
Thanks,



Shared Memory Functions
http://fi.php.net/manual/en/ref.shmop.php

Both clients share a memoryblock where messages are read and written. You might need of course some sort of locking system. When recieving the message, the script tries to set it's semaphore in the memoryblock, then test if it got it, then write to it, then release the semaphore and raise a flag indicating that there is a new message waiting for the other participant.

Both connections should be kept alive all the time, sending empty spaces every now and then should keep it alive. Time-outing must be disabled of course. I think it could work. It would be fun to develope. I've never used shmop thou, so I might be wrong, but that's the closest thing php has to "threads" AFAIK.


Shared memory isn't the problem. The problem is you cannot keep the connection open.

Sending spaces will keep it open for a bit - but that means keeping your php code running all the time. And you can't do that unless you set the timeout parameter to a very large value. And that's not a good idea - what happens if another script starts looping, for instance.

Even then the browser and/or server are free to close the connection if they feel it's been open too long, and most browsers will have a limit as to how long they will wait for data (even if some is still coming down the pipe).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: browsing over VPN
    ... the domain to prevent browsing bypassing the VPN connection. ... workgroup, and no funny entries appear in WINS. ... the client doesn't correctly browse the domain LAN. ... So it tries to resolve the Domain Master Browser using WINS,but ...
    (microsoft.public.win2000.ras_routing)
  • Re: remoting client in IIS request server waiting permenantly when the network connection broken
    ... my client side open a browser to browse a page in the client side (localhost ... client side to server side. ... When the connection resume, the broswer still waiting, and i ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: remoting client in IIS request server waiting permenantly when the network connection broken
    ... my client side open a browser to browse a page in the client side (localhost ... client side to server side. ... When the connection resume, the broswer still waiting, and i ...
    (microsoft.public.dotnet.general)
  • Re: SSL VPN devices?
    ... client piece via the browser. ... connection and de-funneled on the other end. ... We use Check Point's Connectra SSL VPN. ...
    (microsoft.public.windows.terminal_services)
  • Re: SQL Server 2K connection is interrupted regularly, why ?
    ... > within a client request. ... > the connection is back again and anything proceeds very well. ... > connects with the same SQL server Database copied to another PC with the ... I found that if I turned of Shared Memory in the Client Configuration ...
    (microsoft.public.sqlserver.connect)

Loading