Results 1 to 7 of 7

Thread: client server interaction

  1. #1
    Join Date
    Mar 2007
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default client server interaction

    hi,
    I have been given an assignment where I need to create a basic chat window application using only PHP between two systems , one acting as server and other as client . I need to know how to connect the client machine to server machine using IP, Port number and sockets.
    i need to do this at the earliest,but don't have a clue.
    Can someone please help.
    thanks in advance..
    suk

  2. #2
    Join Date
    Mar 2007
    Location
    Tarboro, NC
    Posts
    290
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default

    One: if this is an assignment, I don't think I should do it for you. Two: I wasn't aware that PHP could do that...I thought it would need help from Ajax/Flash. Anyways, someone who does know how to do that (if its possbile) will be along sometime to help you out. Good luck.

    Tim
    Wow, I was just reading past posts and man I was a butthole sometimes to people. So if you ever got the end of it, then sorry...

  3. #3
    Join Date
    Mar 2007
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i was not asking any1 to do it for me.. what i was asking was for a guideline..
    thanks anyways

  4. #4
    Join Date
    Mar 2007
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    and it is possible... just getting some errors.. and if you don't know anything abt it..den ur reply was meaningless...

  5. #5
    Join Date
    Mar 2007
    Location
    Tarboro, NC
    Posts
    290
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default

    Yes, it was. I figured you'd like to know atleast someone read and tried. Some people get impatient.
    Wow, I was just reading past posts and man I was a butthole sometimes to people. So if you ever got the end of it, then sorry...

  6. #6
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Quote Originally Posted by sukanya.paul View Post
    it is possible... just getting some errors..
    Post the code you have so far and the errors that you are getting.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  7. #7
    Join Date
    May 2007
    Location
    By the beach
    Posts
    23
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    The easiest method for PHP chat is via HTTP (port 80). However, if you are required to use sockets you would want to use the PHP fsockopen() module (php.net/fsockopen). This module will allow you to open a socket connection for both reading/writing. It also allows you to manage the resource connection as if you where working with a file (thank you PHP). Meaning you can use the PHP file modules to work with the socket connection, fread(), fwrite(), etc...


    resource fsockopen ( string $hostname [, int $port [, int &$errno [, string &$errstr [, float $timeout ]]]] )

    Example #1 fsockopen() Example (php.net/fsockopen)
    PHP Code:
    <?php
    $fp 
    fsockopen("www.example.com"80$errno$errstr30);
    if (!
    $fp) {
        echo 
    "$errstr ($errno)<br />\n";
    } else {
        
    $out "GET / HTTP/1.1\r\n";
        
    $out .= "Host: www.example.com\r\n";
        
    $out .= "Connection: Close\r\n\r\n";

        
    fwrite($fp$out);
        while (!
    feof($fp)) {
            echo 
    fgets($fp128);
        }
        
    fclose($fp);
    }
    ?>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •