|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37721 socket_recv() don't returns expected value when useing some flags
Submitted: 2006-06-06 22:13 UTC Modified: 2006-06-06 23:54 UTC
From: krzycho at wapp dot pl Assigned:
Status: Not a bug Package: Sockets related
PHP Version: 4.4.2 OS: FreeBSD 5.4-R
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: krzycho at wapp dot pl
New email:
PHP Version: OS:


 [2006-06-06 22:13 UTC] krzycho at wapp dot pl
some flags don't work correctly, cause returned value is not value returned by the recv() function...
some flags work correct(ex. MSG_PEEK), cause it don't modify value returned by the recv.

sockets.c (line 322): m = recv(bsd_socket, (void *) t, 1, flags);
sockets.c (line 341): return n;
should be when we use some flags: return m;

Reproduce code:
define("MSG_OOB",       1); 
define("MSG_PEEK",      2); 
define("MSG_DONTROUTE", 4); 
define("MSG_EOR",       8); 
define("MSG_TRUNC",     16);
define("MSG_CTRUNC",    32);
define("MSG_WAITALL",   64);
$flag=socket_recv($read, $data, 1024, MSG_TRUNC);
echo $flag;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-06 22:20 UTC]
Care to add expected and actual results?

 [2006-06-06 22:43 UTC] krzycho at wapp dot pl
when packet was send by:
socket_send ( resource socket, string buf, 1500, int flags )
real packet size will be 1500, and when we receive data return value should be that 1500 insend of that we currentlty read 1024... and we cound know that when we read again we got same packet.

linux man 2 recv:
Return the real length of the packet, even when  it  was  longer
than the passed buffer. Only valid for packet sockets.

i think it's enough example...
 [2006-06-06 22:55 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.

We need BOTH expected *AND* actual results.

 [2006-06-06 23:43 UTC] krzycho at wapp dot pl
i searched again... and found that it rather depend on os not php... so it's os case(on linux should work, on bsd should work diffrent). php is ok ;)

sorry for problem, my mistake
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat May 21 03:05:45 2022 UTC