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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at 3r1c dot eu
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 20:01:29 2024 UTC