|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-08-31 13:22 UTC] david dot schueler at wapkamera dot de
Description:
------------
If i execute the script below, it will not send the text "REGISTER" over UDP. If the text is prepended with any other character or sent to another port it will be transmitted successful.
Reproduce code:
---------------
<?php
$opts = array('socket' => array("bindto" => "0:5050")); // set source port = 5050
$context = stream_context_create($opts);
$socket = stream_socket_client("udp://127.0.0.1:5060", $errno, $error, 30, STREAM_CLIENT_CONNECT, $context);
fwrite($socket,'REGISTER \r\n');
?>
Expected result:
----------------
The text "REGISTER" followed by a line break to be send over UDP to the given host and port.
Actual result:
--------------
Nothing happens. No packet gets generated, no error or warning is thrown. fwrite() retuns 0.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 11:00:01 2025 UTC |
Yes i wanted to send as line feed. But it doesn't matter because even sending "REGISTER \r\n" nor "REGISTER abc" is working on 5.2.10. I made a little script for showing what is happening: <?php echo phpversion()."\n"; $opts = array('socket' => array("bindto" => "0:5050")); $context = stream_context_create($opts); $socket = stream_socket_client("udp://127.0.0.1:5060", $errno, $error, 30, STREAM_CLIENT_CONNECT, $context); $s[] = "REGISTER abc"; $s[] = "REGISTER"; $s[] = " REGISTER"; $s[] = "REGISTER "; foreach ($s as $out) { echo "Outputting: \"".$out."\"\n"; $bytes = fwrite($socket,$out); echo "Bytes written to socket: ".$bytes."\n"; } ?> And the output is: Kienzle ~ # php fwrite.php 5.2.10-pl0-gentoo Outputting: "REGISTER abc" Bytes written to socket: 0 Outputting: "REGISTER" Bytes written to socket: 8 Outputting: " REGISTER" Bytes written to socket: 9 Outputting: "REGISTER " Bytes written to socket: 9 Kienzle ~ # uname -a Linux Kienzle 2.6.27-gentoo-r8 #7 SMP Wed Apr 29 18:42:19 CEST 2009 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 6000+ AuthenticAMD GNU/Linux On another system, running the same version of php: km33 ~ # php test.php 5.2.10-pl0-gentoo Outputting: "REGISTER abc" Bytes written to socket: 0 Outputting: "REGISTER" Bytes written to socket: 8 Outputting: " REGISTER" Bytes written to socket: 9 Outputting: "REGISTER " Bytes written to socket: 9 km33 ~ # uname -a Linux km33902 2.6.30-gentoo-r4 #2 SMP Tue Aug 4 17:44:21 CEST 2009 x86_64 AMD Phenom(tm) 9950 Quad-Core Processor AuthenticAMD GNU/Linux And for example on a Debian System: ns20 ~ # php test.php 5.2.0-8+etch15 Outputting: "REGISTER abc" Bytes written to socket: 12 Outputting: "REGISTER" Bytes written to socket: 0 Outputting: " REGISTER" Bytes written to socket: 9 Outputting: "REGISTER " Bytes written to socket: 0 evil@ns2014921:~$ uname -a Linux ns2014921.ovh.net 2.6.24.2-xxxx-std-ipv4-32 #4 SMP Wed Feb 13 16:50:04 CET 2008 i686 GNU/Linux Look, the problem occures at "REGISTER". I use "tcpdump -i lo -s0 -A port 5060" to look for the packet being sent. And if fwrite() returns 0 then there arent any bytes on the interface. So the output seems to be true.