Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004

    Any idea how to implement this in PHP

    Any idea how to implement this in PHP

    1. Socket Connection,
    2. Once it authenticated let the client remain connect with server,
    3. Sent Data to the server after pass the above two steps,
    4, Close the connection when we want to,

    I am facing problem, when i try to implement connection,authentication,data transfer,diconnection, one start and one stop (i forgot the method sequntial hope)

    But i prefer to be like even driven, like through buttons, any one wana contribute somthing

    $fp = fsockopen("", 1111, $errno, $errstr,0);
    Sleep (500);
    if (!$fp) {
    echo "$errstr ($errno)<br />\n";
    } else {
    fputs($fp, $buff); -----<<< here i sent my authentication data irst

    -----<<< here i supposed to sent data

    while (!feof($fp)) {
    $response=fgets($fp, 4096);
    echo "This is from Fm Server=".strval(ord($response[$i]));
    echo "\r\n";

  2. #2
    Problem with using form buttons to do actions is the connection will be closed once the Apache process is done sending data to the browser. Thus you'd have to open a new socket each time you want to do something in that sort of model.
    Advanced Forum Hosting
    Easily build a community today!

  3. #3
    Yeah, I'd imagine it would close the socket once the page had finished outputting - or it would stay open forever (and you'd end up with 100s of open sockets)

  4. #4
    You would need to get change your fsockopen to pfsockopen

    pfsockopen() works exactly like fsockopen but the connection is not closed once the script finishes executing. You need to make sure you have limits and the enviroment well defined or you could run into some serious problems.

    do a function search on for more info

Posting Permissions

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