|
Posted by Jerry Stuckle on 10/03/06 12:16
Kimmo Laine wrote:
> "Lenard Redwood" <freakingcrazy@gmail.com> wrote in message
> news:1159809523.767613.115970@m73g2000cwd.googlegroups.com...
>
>>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@attglobal.net
==================
Navigation:
[Reply to this message]
|