Bug #55814 [NEW]: stream_socket_recvfrom() “randomly” returns false

From: Date: Thu, 29 Sep 2011 14:23:07 +0000
Subject: Bug #55814 [NEW]: stream_socket_recvfrom() “randomly” returns false
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-163977@lists.php.net to get a copy of this message
From:             
Operating system: Windows 7
PHP version:      Irrelevant
Package:          Streams related
Bug Type:         Bug
Bug description:stream_socket_recvfrom() “randomly” returns false

Description:
------------
Sometimes, on Windows7 with PHP5.3+, stream_socket_recvfrom() returns false
(the documentation says that it always returns a string but the source code
says the opposite, it can return false), and I have no idea why. It happens
only on Windows7 a priori. Basically, I have a client and a server as
bellow.

Test script:
---------------
Client.php

<?php
 
$client = stream_socket_client(
    'tcp://127.0.0.1:9001',
    $errno,
    $errstr,
    30,
    STREAM_CLIENT_CONNECT
);
echo 'Received ';
var_dump(stream_socket_recvfrom($client, 6));


Server.php

<?php
 
$server = stream_socket_server(
    'tcp://127.0.0.1:9001',
    $errno,
    $errstr,
    STREAM_SERVER_BIND | STREAM_SERVER_LISTEN
);
echo 'Up & listen…', "\n";
$client = stream_socket_accept($server);
echo 'New connection', "\n";
stream_socket_sendto($client, 'foobar');
echo 'Sent “foobar”', "\n";

Expected result:
----------------
Client.php
Received: string(6) "foobar"

Server.php
Up & listen…
New connection
Sent “foobar”

Actual result:
--------------
Client.php
Sometimes: Received: string(6) "foobar"
Sometimes: Received: bool(false)

Server.php
Up & listen…
New connection
Sent “foobar”

-- 
Edit bug report at https://bugs.php.net/bug.php?id=55814&edit=1
-- 
Try a snapshot (PHP 5.4):            https://bugs.php.net/fix.php?id=55814&r=trysnapshot54
Try a snapshot (PHP 5.3):            https://bugs.php.net/fix.php?id=55814&r=trysnapshot53
Try a snapshot (trunk):              https://bugs.php.net/fix.php?id=55814&r=trysnapshottrunk
Fixed in SVN:                        https://bugs.php.net/fix.php?id=55814&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55814&r=needdocs
Fixed in release:                    https://bugs.php.net/fix.php?id=55814&r=alreadyfixed
Need backtrace:                      https://bugs.php.net/fix.php?id=55814&r=needtrace
Need Reproduce Script:               https://bugs.php.net/fix.php?id=55814&r=needscript
Try newer version:                   https://bugs.php.net/fix.php?id=55814&r=oldversion
Not developer issue:                 https://bugs.php.net/fix.php?id=55814&r=support
Expected behavior:                   https://bugs.php.net/fix.php?id=55814&r=notwrong
Not enough info:                     https://bugs.php.net/fix.php?id=55814&r=notenoughinfo
Submitted twice:                     https://bugs.php.net/fix.php?id=55814&r=submittedtwice
register_globals:                    https://bugs.php.net/fix.php?id=55814&r=globals
PHP 4 support discontinued:          https://bugs.php.net/fix.php?id=55814&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=55814&r=dst
IIS Stability:                       https://bugs.php.net/fix.php?id=55814&r=isapi
Install GNU Sed:                     https://bugs.php.net/fix.php?id=55814&r=gnused
Floating point limitations:          https://bugs.php.net/fix.php?id=55814&r=float
No Zend Extensions:                  https://bugs.php.net/fix.php?id=55814&r=nozend
MySQL Configuration Error:           https://bugs.php.net/fix.php?id=55814&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#163977) next »