php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39068 8Kb write buffer on nonblock sockets
Submitted: 2006-10-06 17:56 UTC Modified: 2006-10-06 18:05 UTC
From: dmitrysp at yandex dot ru Assigned:
Status: Not a bug Package: Sockets related
PHP Version: 5.1.6 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dmitrysp at yandex dot ru
New email:
PHP Version: OS:

 

 [2006-10-06 17:56 UTC] dmitrysp at yandex dot ru
Description:
------------
PHP on Windows can't write more 8192 bytes in nonblock mode socket (on Linux or in blocked mode - no problems). And stream_set_write_buffer() not work - buffer all time is only 8Kb.

About error 10035 in *.h files:

The network operation would block.
#define WINSOCK_WSAEWOULDBLOCK           0x00002733L

A non-blocking socket operation could not be completed immediately.
#define WSAEWOULDBLOCK                   10035L

Reproduce code:
---------------
<?
    error_reporting(E_ALL);
    $f=fsockopen("www.php.net",80);
    var_dump(stream_set_write_buffer($f,50000));// no effects, always -1 on any size
    stream_set_blocking($f,0);
    $post=str_repeat('b',9000); // 7000 - work, 8192 or more not work
    $str="POST / HTTP/1.0\r\n".
         "HOST: www.php.net\r\n".
         "Content-Type: application/x-www-form-urlencoded\r\n".
         "Content-Length: ".strlen($post)."\r\n\r\n$post";
    echo "fputs():\r\n".substr($str,0,1000)."\r\n";
    fputs($f,$str);
      // Notice: fputs(): send of 917 bytes failed with errno=10035 &#1054;&#1087;&#1077;&#1088;&#1072;&#1094;&#1080;&#1103; 
      // &#1085;&#1072; &#1085;&#1077;&#1079;&#1072;&#1073;&#1083;&#1086;&#1082;&#1080;&#1088;&#1086;&#1074;&#1072;&#1085;&#1085;&#1086;&#1084; &#1089;&#1086;&#1082;&#1077;&#1090;&#1077; &#1085;&#1077; &#1084;&#1086;&#1078;&#1077;&#1090; &#1073;&#1099;&#1090;&#1100; &#1079;&#1072;&#1074;&#1077;&#1088;&#1096;&#1077;&#1085;&#1072; &#1085;&#1077;&#1084;&#1077;&#1076;&#1083;&#1077;&#1085;&#1085;&#1086;.
    while (!feof($f)) {
        echo fread($f,100000);
        sleep(1);
    }
?>

Expected result:
----------------
I want use fputs() with big http-request and use nonblock fsockopen ;-)

Actual result:
--------------
fputs($f,$str); without notice and sockets bug on 8Kb buffer

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-06 18:05 UTC] tony2001@php.net
Windows limitations are by no means PHP bugs.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 06:01:27 2025 UTC