|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-03-16 00:19 UTC] sniper@php.net
[2005-03-24 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 13:00:01 2025 UTC |
Description: ------------ I am trying to recieve data via a UDP socket using the socket_recvfrom function. It works fine unless there is a null char anywhere in the packet. If there is the buffer returned only contains data up to that point, although the value returned by the function shows there is actually more data. Reproduce code: --------------- if (!$sock=socket_create(AF_INET,SOCK_DGRAM,SOL_UDP)) { echo "<b>Error:</b> Failed to create socket, ".socket_strerror(socket_last_error($sock))."<br>\n"; } elseif (!socket_bind($sock,"0.0.0.0",41330)) { echo "<b>Error:</b> Failed to bind socket, ".socket_strerror(socket_last_error($sock))."<br>\n"; socket_close($sock); } else { echo "<b>Ready, please send a message to port 41330 using UDP</b><br><br>\n"; $size=socket_recvfrom($sock,$buf,65535,0,$clientIP,$clientPort); if ($buf===FALSE) { echo "<b>Error:</b> Returned false, ".socket_strerror(socket_last_error($sock))."<br>\n"; } else { echo "Message from ".$clientIP.":".$clientPort." (".strlen($buf)."/".$size." bytes)...<br>\n"; } socket_close($sock); } Expected result: ---------------- All data to be placed into the buffer regardless of any null characters in the packet. Actual result: -------------- If you send a datagram to port 41330 while this is running with a null character mid way into the packet, any data from there onwards will not be placed into $buf.