Bug #66266 [NEW]: socket_sendto always returns true
| From: | chuck at jumis dot com | Date: | Thu, 12 Dec 2013 00:51:14 +0000 |
| Subject: | Bug #66266 [NEW]: socket_sendto always returns true | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-183245@lists.php.net to get a copy of this message | ||
From: chuck at jumis dot com
Operating system: Darwin Kernel Version 13.0.0
PHP version: 5.4.22
Package: Sockets related
Bug Type: Bug
Bug description:socket_sendto always returns true
Description:
------------
This always returns true, and the full amount of bytes, even when the
remote port is closed. Running socket_recvfrom simply results in an
Unavailable error.
This is in contrast to running something like socat which will return an
error after sending data. Note that the manual does say that UDP
connections should return an error following socket_sendto.
I've not been able to find a work-around. At present I simply can not
test if the target UDP port is open. May be an ICMP issue.
Test script:
---------------
$fp = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$bytes = socket_sendto($fp, $json."\n", strlen($json)+1, 0, $ip,
$port);
$fp && $bytes > 0 && socket_last_error($fp) == 0;
Expected result:
----------------
When the remote UDP port is closed, socket_sendto should return false or
otherwise socket_recvfrom should return false.
Actual result:
--------------
The socket pointer and socket_sendto return true -- it is not
distinguishable whether or not the remote UDP port is open.
--
Edit bug report at https://bugs.php.net/bug.php?id=66266&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66266&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66266&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66266&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66266&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66266&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66266&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66266&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66266&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66266&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66266&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66266&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66266&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66266&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66266&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66266&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66266&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66266&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66266&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66266&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66266&r=mysqlcfg