|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32324 socket_recvfrom stops reading at null char
Submitted: 2005-03-15 20:19 UTC Modified: 2005-03-24 01:00 UTC
From: admin at freeworldonline dot com Assigned:
Status: No Feedback Package: Sockets related
PHP Version: 4.3.10 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
15 + 16 = ?
Subscribe to this entry?

 [2005-03-15 20:19 UTC] admin at freeworldonline dot com
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,"",41330)) {
	echo "<b>Error:</b> Failed to bind socket, ".socket_strerror(socket_last_error($sock))."<br>\n";
	} else {
	echo "<b>Ready, please send a message to port 41330 using UDP</b><br><br>\n";
	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";

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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-16 00:19 UTC]
Please try using this CVS snapshot:
For Windows:

I can not reproduce this. I get only "Message from (363/363 bytes)..." 

 [2005-03-24 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 23:01:29 2024 UTC