Home » Networking » Net_Socket » Bug #980
Block write works better on Windows XP
Details
| Submitted | 2004-03-09 13:18 UTC |
|---|---|
| From | ash at bigfoot dot de |
| Assigned | chagenbu |
| Status | Closed |
| Package | Net_Socket |
| PHP Version | 5.0.0b4 (beta4) |
| OS | Windows NT HAL 5.1 build 2600 |
| Roadmaps | (Not assigned) |
Comments
[2004-03-09 13:18 UTC] ash at bigfoot dot de
Description:
------------
I tried to send big emails with PEAR Mail, but there always occured this, regardless of isBlocking() = TRUE or FALSE:
PHP Notice: fputs(): send of 8192 bytes failed with errno=0
Resource temporarily unavailable.
This seemed to be WinSock error 10035: WSAEWOULDBLOCK, so I changed the write method to send blocks of data.
The PHP Notice now comes for every call of fwrite, but the mail can be send. An @ before fwrite even let the PHP Notices disappear ;-)
Keep up the good work,
René
Reproduce code:
---------------
function write($data, $blocksize = 8192) {
if (is_resource($this->fp)) {
$pos = 0;
$size = strlen($data);
while($pos < $size) {
$written = fwrite($this->fp, substr($data, $pos, $blocksize), $blocksize);
if(FALSE === $written)
return FALSE;
$pos += $written;
}
return $pos;
}
return $this->raiseError("not connected");
}
[2004-04-04 03:33 UTC] chris at lodesys dot com
Ran into the same problem with 5.0.0RC1. Tried René's patch, which helped, but still having problems with the large $blocksize. Changed the blocksize & modified the fwrite call. Now able to send large PDF files as attachments without errors. Running Apache 1.3.28 & PHP/5.0.0RC1 under Windows 2000 SP3.
My version of the patch is as follows...
function write($data, $blocksize = 1280) {
if (is_resource($this->fp)) {
$pos = 0;
$size = strlen($data);
while($pos < $size) {
@$written = fwrite($this->fp, substr($data, $pos, $blocksize));
if(FALSE === $written)
return FALSE;
$pos += $written;
}
return $pos;
}
return $this->raiseError("not connected");
}
Not pretty, but it works.