Chatting using PHP ?

Discussion in 'PHP' started by priyakochin, Jun 9, 2007.

  1. #1
    Can anyone please help me to create a chat with php using sockets ?

    Please help me with some resource sites or links !
     
    priyakochin, Jun 9, 2007 IP
  2. *louie*

    *louie* Peon

    Messages:
    48
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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.
     
    *louie*, Jun 9, 2007 IP
  3. priyakochin

    priyakochin Banned

    Messages:
    4,740
    Likes Received:
    138
    Best Answers:
    0
    Trophy Points:
    0
    #3
    But I don't know Ajax !
    I want it to be done with php
     
    priyakochin, Jun 9, 2007 IP
  4. *louie*

    *louie* Peon

    Messages:
    48
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ajax can be used with php without a problem.
    follow the link above for Google and you'll get lots of scripts ready-made.
     
    *louie*, Jun 9, 2007 IP
  5. priyakochin

    priyakochin Banned

    Messages:
    4,740
    Likes Received:
    138
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I want to do it alone using socket !
    So can anyone help !
     
    priyakochin, Jun 9, 2007 IP
  6. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #6
    i think he's looking for like a phpbot type deal for irc.
     
    ansi, Jun 9, 2007 IP
  7. ZenOswyn

    ZenOswyn Peon

    Messages:
    50
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    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).
     
    ZenOswyn, Jun 9, 2007 IP
  8. mrmonster

    mrmonster Active Member

    Messages:
    374
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #8
    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.
     
    mrmonster, Jun 9, 2007 IP
  9. priyakochin

    priyakochin Banned

    Messages:
    4,740
    Likes Received:
    138
    Best Answers:
    0
    Trophy Points:
    0
    #9
    So can you plz tell me some resource sites of this ?
     
    priyakochin, Jun 9, 2007 IP
  10. KalvinB

    KalvinB Peon

    Messages:
    2,787
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #10
    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.
     
    KalvinB, Jun 11, 2007 IP