View Full Version : Chatting using PHP ?
priyakochin
Jun 9th 2007, 6:07 am
Can anyone please help me to create a chat with php using sockets ?
Please help me with some resource sites or links !
*louie*
Jun 9th 2007, 12:08 pm
What about using ajax?
google.ie/search?sourceid=navclient&ie=UTF-8&rls=GGLJ,GGLJ:2006-49,GGLJ:en&q=ajax+php+chat
very good scripts out there already.
priyakochin
Jun 9th 2007, 12:21 pm
But I don't know Ajax !
I want it to be done with php
*louie*
Jun 9th 2007, 12:24 pm
Ajax can be used with php without a problem.
follow the link above for Google and you'll get lots of scripts ready-made.
priyakochin
Jun 9th 2007, 12:26 pm
I want to do it alone using socket !
So can anyone help !
ansi
Jun 9th 2007, 2:53 pm
i think he's looking for like a phpbot type deal for irc.
ZenOswyn
Jun 9th 2007, 2:55 pm
I think you're going to have a hard time finding someone to 'help' with a chat program like you want. My advice would be to use google until you find what you are looking for, or pay someone to do it for you (assuming you can't wait).
mrmonster
Jun 9th 2007, 7:05 pm
Using sockets? What exactly does that mean, you might be confusing this with Unix sockets where you can create a client/server setup.
For a PHP based chat setup, you need constant calls to the server to check for new data. Whenever a user types something, it has to be saved on the server so the other participants can get it the next time their client checks for new chat data.
You could use AJAX to make it a little more transparent to the end user, but it still needs to continually connect to the serve to check for new data.
This type of a chat might work OK for a few people, but if you want a large number of users the server requirements will go up quickly. Each connected user needs to send a request to the server every second or so, depending on how "instant" you want the chat to be.
A "true chat" would involve something like an Enterprise Java server on the back-end, where you have a service running, and an applet on the client side.
priyakochin
Jun 9th 2007, 7:12 pm
So can you plz tell me some resource sites of this ?
KalvinB
Jun 11th 2007, 1:10 pm
PHP supports raw sockets and can be used to run client/server apps. You just need to use the
http://us2.php.net/manual/en/function.fsockopen.php
fsockopen function to open the connection to whatever you're chatting with. You can then write data to that connection just like writing data to a file.
If you want to write a PHP chat server you can use
http://us2.php.net/manual/en/function.socket-accept.php
and other socket functions to listen and respond to requests.
If you want this web-based then yes, ajax would be the way to go. But if you just want a stand alone PHP app then you can use sockets. You just need to learn the protocol of the server so you know what data to send and how to interpret the data coming back.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.