I'd like to create a simple chat application that will leave the
connection open for a minute and then restart the connection to the
server to push data. I plan to use temporary .txt files to store
messages. My question is how can I do that in PHP 5, what techniques
should I do server-side to keep this connection open and how would be
the flow of the message? Do I need a different technology such as
Python to handle messages?
1. User A sends a message to the server
2. ?
3. User B receives the message instantly through an open connection
Any tip/link/tutorial would be greatly appreciated.
Thanks,
Lenard. 7 1629
Lenard Redwood wrote:
I'd like to create a simple chat application that will leave the
connection open for a minute and then restart the connection to the
server to push data. I plan to use temporary .txt files to store
messages. My question is how can I do that in PHP 5, what techniques
should I do server-side to keep this connection open and how would be
the flow of the message? Do I need a different technology such as
Python to handle messages?
1. User A sends a message to the server
2. ?
3. User B receives the message instantly through an open connection
Any tip/link/tutorial would be greatly appreciated.
Thanks,
Lenard.
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.
The other alternative is something like a Java applet where you can
maintain a connection.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
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,
Lenard
Lenard Redwood wrote:
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,
Lenard
That's what I'm saying. You can't with the http protocol. It's not
designed for that.
Use javascript to update regularly or another tool such as java which
can define its own protocol (java on the server and an applet on the
client).
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
"Lenard Redwood" <fr***********@ gmail.comwrote in message
news:11******** **************@ m73g2000cwd.goo glegroups.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.
--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis sp**@outolempi. net || Gedoon-S @ IRCnet || rot13(xv***@bhg byrzcv.arg)
Kimmo Laine wrote:
"Lenard Redwood" <fr***********@ gmail.comwrote in message
news:11******** **************@ m73g2000cwd.goo glegroups.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. js*******@attgl obal.net
=============== ===
Lenard Redwood wrote:
How about keeping the connection open for a minute, then reopen it?
Services like Gtalk (http://mail.google.com/mail/help/chat.html),
Interaction (http://www.interactionchat.com/) and Meebo
(http://www.meebo.com/) use an open-connection and this allows
reception of new messages instantly without the need of a Java applet
or a Flash application. There's gotta be a way...
I don't know about Gtalk - I don't do Gmail, so I don't know how they do it.
Interactionchat and Meebo both use Ajax, so I suspect they're using
javascript to poll the server.
No, there is absolutely no way - nada - zip - zero to the infinite power
- way to "push" data with the http protocol. It is strictly a
request/response protocol, with the request initiated by the client.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== === This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Daniel Ruscoe |
last post by:
Hi chaps,
I'm relatively new to the language, but I want to create a simple order
form using PHP and cookies. Please let me know if there's a better way
in this situation, database isn't availible.
What I'm trying to get is this:
1) Variable(A) passed from HTML page to script.
2) Script checks for cookie.
|
by: flupke |
last post by:
Hi,
i'm trying to convert my java console app to a python gui.
Now, the only problem i seem to have at the moment are the resizers
for the layout. It seems that for the purpose of what i'm trying to do,
specifying the coordinates is easier that fighting with the layout resizers.
1) I have a screen split in 2. Left side is a textcontrol where logging will
end up. All text will be appended to the textcontrol. Ideally this should
allow...
|
by: Lauren Wilson |
last post by:
Hi folks,
Somewhere, I recently saw an article header titled:
"How to compact and Repair a back-end Access db from the front-end
using VBA" or words to that effect.
Now that I need it, I cannot find it. Does anyone know were to find
such an article?
|
by: C Sharp beginner |
last post by:
I'm sorry about this verbose posting. This is a follow-up
to my yesterday's posting. Thanks William for your reply.
I understand it is a good practice to open connections as
late as possible and close them as early as possible.
My requirement is as follows:
I'm developing a class library that will be instantiated
by a COM component. My class library contains functions
that perform lot of mathematical calculations and read a
lot of data...
|
by: Shaniqua Jones |
last post by:
I've designed a C# application consisting of two EXEs: a client and
server. The server runs on my Win2000 Server box, and the client runs on my
customers' machines -- typically XP. The client app connects to the server,
makes a request, and awaits a response. The server sends back the response
at which point the client disconnects. The connection takes place on port
20198 (TCP). My server app was coded in such a way that only 10...
| |
by: ʹÃûÑï |
last post by:
ORA-03114: not connected to ORACLE && MS's Bug??
DataBase:Oracle 817
using OracleClient,net framework 1.1
I'm using ADO.Net in C# with Oracle 817.
and following is my public data access class.
using System.Data.OracleClient;
|
by: Jon Maz |
last post by:
Hi,
I just read the following in an old NG thread:
"when you use the adapter with a closed connection it will open it, do your
requested database access, and close it immediately. If you use the adapter
with an open connection the connection will continue to be open after the
adapter is done."
My DataLayer makes extensive use of DataAdapters to fill DataSets, and
|
by: gunimpi |
last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431
********************************************************
VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help
wanted
********************************************************
For this teeny job, please refer to:
http://feeds.reddit.com/feed/8fu/?o=25
|
by: Usman Jamil |
last post by:
Hi
I've a class that creates a connection to a database, gets and loop on a
dataset given a query and then close the connection. When I use netstat
viewer to see if there is any connection open left, I always see that there
are 2 connections open and in "ESTABLISHED" state. Here is the piece of code
that I'm using, please tell where I'm doing it wrong. Since this class is
being used at many placed in my actual web based application that...
|
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...
|
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...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |