Professional Web Applications Themes

#22263 [Opn->Fbk]: socket_read() crashes on client close - PHP Development

ID: 22263 Updated by: [email]pollitaphp.net[/email] Reported By: caesar_iv4 at yahoo dot com -Status: Open +Status: Feedback Bug Type: Sockets related Operating System: win 98 SE PHP Version: 4.3.2-dev New Comment: As Wez mentioned your script is incomplete. You havn't defined the $SRV structure. Sure we could guess at valid values, but it's important we know what YOU'RE attempting to pass. Your socket_connect() line is simply wrong. Check the manual. Also, when providing a reproducing script, only provide as much as is necessary to reproduce the problem. This means NO watchpoints, NO commented out code lines, NO logging functions. The only ...

  1. #1

    Default #22263 [Opn->Fbk]: socket_read() crashes on client close

    ID: 22263
    Updated by: [email]pollitaphp.net[/email]
    Reported By: caesar_iv4 at yahoo dot com
    -Status: Open
    +Status: Feedback
    Bug Type: Sockets related
    Operating System: win 98 SE
    PHP Version: 4.3.2-dev
    New Comment:

    As Wez mentioned your script is incomplete.

    You havn't defined the $SRV structure.
    Sure we could guess at valid values, but it's important we know what
    YOU'RE attempting to pass.

    Your socket_connect() line is simply wrong.
    Check the manual.

    Also, when providing a reproducing script, only provide as much as is
    necessary to reproduce the problem. This means NO watchpoints, NO
    commented out code lines, NO logging functions. The only time pieces
    of the above should be including in a reproducing script is when they
    are necessary to cause the error. In your case, they aren't.

    Finally, I'd like to ask if you've been able to reproduce this on any
    other platforms. Win2K? XP? 95? NT4? NT3? Any variant of unix?

    Thank you for your time and effort and I hope that together we can
    locate and deal with this problem.


    Previous Comments:
    ------------------------------------------------------------------------

    [2003-03-21 22:01:13] caesar_iv4 at yahoo dot com

    wez
    i don't know wheather you read the title
    but the script crashes at
    $buf = socket_read($msgsock, 2048, PHP_BINARY_READ);
    whenever i close the connection using IE6 on Windows 98

    ------------------------------------------------------------------------

    [2003-03-18 12:36:23] [email]wezphp.net[/email]

    Please try using this CVS snapshot:

    [url]http://snaps.php.net/php4-STABLE-latest.tar.gz[/url]

    For Windows:

    [url]http://snaps.php.net/win32/php4-win32-STABLE-latest.zip[/url]

    Can't reproduce using supplied script + latest CVS for 4.3.2 under
    winxp.

    Please be more specific about the error and where the script fails.

    It would also help if we don't have to fill in the other half of your
    script - please try to paste a script that reproduces the problem,
    preferably around 10 lines in length.


    ------------------------------------------------------------------------

    [2003-02-18 23:00:24] [email]sniperphp.net[/email]

    correct PHP version..


    ------------------------------------------------------------------------

    [2003-02-17 23:51:11] caesar_iv4 at yahoo dot com

    I use php 4.3.2 latest cvs
    even php 5 and it stil occurs

    i am trying to write a small php-based httpdeamon and when i was
    testing it with IE6, open the connection and the page starts loading,
    but when i click on stop i get the usual crashed program box

    here's the script:
    <?
    function& sock() {
    global $SRV;
    if (($sock = socket_create (AF_INET, SOCK_STREAM, 0)) < 0)
    sock_err($sock,"socket_create()");
    if (($ret = socket_bind ($sock, $SRV["IP"], $SRV["PORT"])) < 0)
    sock_err($sock,"socket_bind()");
    if (($ret = socket_listen ($sock, $SRV["MAX_CL"])) < 0)
    sock_err($sock,"socket_listen()");
    return $sock;
    }
    function send(&$sock,$msg,$echo=true) {
    global $CORE_DUMP;
    // socket_write($sock,$msg,strlen($msg));
    fwrite($CORE_DUMP,$msg,strlen($msg));
    if($echo)
    echo $msg;
    }
    function log_access($ip) {
    global $LOG_ACCESS;
    $str = date("r")." ".$ip."\n";
    fwrite($LOG_ACCESS,$str,strlen($str));
    }
    function sock_err(&$sock,$fn) {
    global $LOG_ERROR;
    $str = $fn." failed, reason:
    ".socket_strerror(socket_last_error($sock));
    echo $str;
    fwrite($LOG_ERROR,$str,strlen($str));
    }

    error_reporting (E_ALL);

    set_time_limit (0);
    ob_implicit_flush();
    echo "07\n";
    $sock = &sock();
    echo "09\n";
    do {
    echo "11\n";
    if (($msgsock = socket_accept($sock)) < 0)
    sock_err($msgsock,"socket_accept()");
    echo "14\n";
    socket_getpeername($msgsock,$ip);
    echo "15\n";
    log_access($ip);
    echo "16\n";
    $str = "";
    echo "18\n";
    $i = 0;
    echo "20\n";
    while ($msgsock) {
    echo "23\n";
    if (!$msgsock)
    break;
    echo $msgsock;
    $buf = socket_read($msgsock, 2048, PHP_BINARY_READ);
    echo "25\n";
    if (!$buf) {
    sock_err($msgsock,"socket_read()");
    break;
    }
    echo "26\n";
    echo "28\n";
    }
    echo "38\n";
    socket_close ($msgsock);
    echo "40\n";
    } while ($sock);

    socket_close ($sock);
    ?>

    the echoes were to pin-point the problem



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=22263&edit=1[/url]

    pollita@php.net Guest

  2. #2

    Default #22263 [Opn->Fbk]: socket_read() crashes on client close

    ID: 22263
    Updated by: [email]sniperphp.net[/email]
    Reported By: caesar_iv4 at yahoo dot com
    -Status: Open
    +Status: Feedback
    Bug Type: Sockets related
    Operating System: win 98 SE
    PHP Version: 4.3.2-dev
    New Comment:

    PLEASE read what [email]pollitaphp.net[/email] said in her comment before you add any
    new comments. Your script is pretty much useless to us. Provide the
    shortest but _complete_ example script which we can copy'n'paste to a
    file and with only minor changes run ourselves.



    Previous Comments:
    ------------------------------------------------------------------------

    [2003-07-16 16:56:36] caesar_iv4 at yahoo dot com

    here is the missing $SRV variable:



    $SRV = array(
    "SRVROOT" => "C:/desktop/phpfiles/projects/httpd/",
    "DOCROOT" => "C:/desktop/phpfiles/projects/httpd/docs/",
    "IP" => "127.0.0.1",
    "HOST" => "loclahost",
    "PORT" => 80,
    "LOG" => array(
    "ACCESS"=> "C:/desktop/phpfiles/projects/httpd/log_access.txt",
    "ERROR" => "C:/desktop/phpfiles/projects/httpd/log_error.txt",
    "DUMP" => "C:/desktop/phpfiles/projects/httpd/dump"
    ),
    "MAX_CL" => 3,
    "DIR_INDEX" => array(
    "index.html",
    "index.htm"
    ),
    "READ_BYTES"=> 33
    );

    ------------------------------------------------------------------------

    [2003-07-16 12:36:09] [email]pollitaphp.net[/email]

    As Wez mentioned your script is incomplete.

    You havn't defined the $SRV structure.
    Sure we could guess at valid values, but it's important we know what
    YOU'RE attempting to pass.

    Your socket_connect() line is simply wrong.
    Check the manual.

    Also, when providing a reproducing script, only provide as much as is
    necessary to reproduce the problem. This means NO watchpoints, NO
    commented out code lines, NO logging functions. The only time pieces
    of the above should be including in a reproducing script is when they
    are necessary to cause the error. In your case, they aren't.

    Finally, I'd like to ask if you've been able to reproduce this on any
    other platforms. Win2K? XP? 95? NT4? NT3? Any variant of unix?

    Thank you for your time and effort and I hope that together we can
    locate and deal with this problem.

    ------------------------------------------------------------------------

    [2003-03-21 22:01:13] caesar_iv4 at yahoo dot com

    wez
    i don't know wheather you read the title
    but the script crashes at
    $buf = socket_read($msgsock, 2048, PHP_BINARY_READ);
    whenever i close the connection using IE6 on Windows 98

    ------------------------------------------------------------------------

    [2003-03-18 12:36:23] [email]wezphp.net[/email]

    Please try using this CVS snapshot:

    [url]http://snaps.php.net/php4-STABLE-latest.tar.gz[/url]

    For Windows:

    [url]http://snaps.php.net/win32/php4-win32-STABLE-latest.zip[/url]

    Can't reproduce using supplied script + latest CVS for 4.3.2 under
    winxp.

    Please be more specific about the error and where the script fails.

    It would also help if we don't have to fill in the other half of your
    script - please try to paste a script that reproduces the problem,
    preferably around 10 lines in length.


    ------------------------------------------------------------------------

    [2003-02-17 23:51:11] caesar_iv4 at yahoo dot com

    I use php 4.3.2 latest cvs
    even php 5 and it stil occurs

    i am trying to write a small php-based httpdeamon and when i was
    testing it with IE6, open the connection and the page starts loading,
    but when i click on stop i get the usual crashed program box

    here's the script:
    <?
    function& sock() {
    global $SRV;
    if (($sock = socket_create (AF_INET, SOCK_STREAM, 0)) < 0)
    sock_err($sock,"socket_create()");
    if (($ret = socket_bind ($sock, $SRV["IP"], $SRV["PORT"])) < 0)
    sock_err($sock,"socket_bind()");
    if (($ret = socket_listen ($sock, $SRV["MAX_CL"])) < 0)
    sock_err($sock,"socket_listen()");
    return $sock;
    }
    function send(&$sock,$msg,$echo=true) {
    global $CORE_DUMP;
    // socket_write($sock,$msg,strlen($msg));
    fwrite($CORE_DUMP,$msg,strlen($msg));
    if($echo)
    echo $msg;
    }
    function log_access($ip) {
    global $LOG_ACCESS;
    $str = date("r")." ".$ip."\n";
    fwrite($LOG_ACCESS,$str,strlen($str));
    }
    function sock_err(&$sock,$fn) {
    global $LOG_ERROR;
    $str = $fn." failed, reason:
    ".socket_strerror(socket_last_error($sock));
    echo $str;
    fwrite($LOG_ERROR,$str,strlen($str));
    }

    error_reporting (E_ALL);

    set_time_limit (0);
    ob_implicit_flush();
    echo "07\n";
    $sock = &sock();
    echo "09\n";
    do {
    echo "11\n";
    if (($msgsock = socket_accept($sock)) < 0)
    sock_err($msgsock,"socket_accept()");
    echo "14\n";
    socket_getpeername($msgsock,$ip);
    echo "15\n";
    log_access($ip);
    echo "16\n";
    $str = "";
    echo "18\n";
    $i = 0;
    echo "20\n";
    while ($msgsock) {
    echo "23\n";
    if (!$msgsock)
    break;
    echo $msgsock;
    $buf = socket_read($msgsock, 2048, PHP_BINARY_READ);
    echo "25\n";
    if (!$buf) {
    sock_err($msgsock,"socket_read()");
    break;
    }
    echo "26\n";
    echo "28\n";
    }
    echo "38\n";
    socket_close ($msgsock);
    echo "40\n";
    } while ($sock);

    socket_close ($sock);
    ?>

    the echoes were to pin-point the problem



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=22263&edit=1[/url]

    sniper@php.net Guest

Similar Threads

  1. Replies: 3
    Last Post: July 27th, 12:24 AM
  2. #24797 [Bgs->Opn]: feature request: way to close connection with client?
    By spagmoid at yahoo dot com in forum PHP Development
    Replies: 2
    Last Post: July 26th, 11:42 PM
  3. #24797 [NEW]: feature request: way to close connection with client?
    By spagmoid at yahoo dot com in forum PHP Development
    Replies: 0
    Last Post: July 24th, 08:30 PM
  4. #22263 [Fbk->NoF]: socket_read() crashes on client close
    By sniper@php.net in forum PHP Development
    Replies: 0
    Last Post: July 21st, 06:29 AM
  5. #22263 [Fbk->Opn]: socket_read() crashes on client close
    By caesar_iv4 at yahoo dot com in forum PHP Development
    Replies: 0
    Last Post: July 16th, 09:56 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139