php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46172 fwrite refuses to write more then 32k to non-blocking socket
Submitted: 2008-09-25 11:34 UTC Modified: 2008-09-25 11:45 UTC
From: php at 3r1c dot eu Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.2.6 OS: FreeBSD
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
35 - 1 = ?
Subscribe to this entry?

 
 [2008-09-25 11:34 UTC] php at 3r1c dot eu
Description:
------------
fwrite refuses to write more then 32k to non-blocking socket.
removing the stream_set_blocking line in my sample code will make the program work properly.

It seems to get higher amount written on a localhost socket, about 120kb.

Reproduce code:
---------------
#!/usr/local/bin/php -q
<?php

// create a string with 100kb of zeros
$bytes = "";
for ($i = 0; $i < 100000; $i++){
$bytes .= "0";
}

$sock = @stream_socket_client('tcp://google.com:80', $errno, $errstr, 30);

stream_set_blocking($sock, 0);

$written = fwrite($sock, $bytes);

echo "Wrote $written bytes\n";
fclose($sock);
?>

Expected result:
----------------
Wrote 100000 bytes

Actual result:
--------------
Wrote 32768 bytes

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-25 11:45 UTC] scottmac@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

The default tcp socket send buffer on FreeBSD is 32k, you need to change net.inet.tcp.sendspace to a higher value if you want to write more.


 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 02:01:23 2019 UTC