ID:               15639
 Updated by:       [EMAIL PROTECTED]
 Reported By:      rip at undernet dot org
-Status:           Suspended
+Status:           Closed
 Bug Type:         Network related
 Operating System: All
 PHP Version:      4.1.1
 New Comment:

Wez fixed this in time for PHP 4.3.2

fread() will now act non-greedily when reading from network streams
(i.e. grab the lesser of: one packet or maxlen bytes)

fgets() will continue to act greedily, but it would be inappropriate to
use it with UDP streams anyway.




Previous Comments:
------------------------------------------------------------------------

[2003-05-01 17:43:54] [EMAIL PROTECTED]

The FIRST call to recv() detects end of packet just fine.  The trouble
is, php_stream_read, in its exuberance to fill the read buffer, makes a
SECOND call to php_stream_fill_read_buffer, which in turn makes a
SECOND call to php_sockops_read (via stream->ops->read()) and it's THAT
call which is waiting for a second packet.

This is *bad* behavior for UDP read operations, is there some way we
can tell php_sockop_read if this is the initial call or a subsequent
backfill?

------------------------------------------------------------------------

[2002-09-26 10:30:01] [EMAIL PROTECTED]

If someone comes up with some sample C code that definitely
has the behaviour, I will implement it into PHP.
Until then this is suspended.


------------------------------------------------------------------------

[2002-04-14 13:09:17] rip at undernet dot org

Doesn't seems to change anything.

------------------------------------------------------------------------

[2002-04-13 18:09:59] [EMAIL PROTECTED]

Can you try changing the FG(def_chunk_size) assignment
in the file_globals_ctor function in ext/standard/file.c
and hard-code it to 1.
Then try your UDP script.
If that solves the problem, I will add a method of
setting this from script (using set_file_buffer).
I still don't think using recvfrom will make any
difference.

------------------------------------------------------------------------

[2002-03-16 14:51:31] rip at undernet dot org

It also says it should only be used in connected sockets.
Here is a working exemple from a porky sourcecode I have :
loop:
len = recvfrom(sock, data, 50, 0, (struct sockaddr *)&sai, &s_sai);
printf("%d bytes from %s:%d -
%s\n",len,inet_ntoa(sai.sin_addr),ntohs(sai.sin_port),data);
goto loop;

The default size is 50, if the UDP packet is < 50 (ie:42) it will print
: 42 bytes from 192.168.0.1:8000 - This is only a test. This is only a
test!!

So if you modify the recv call to a recvfrom call, it won't break TCP
and will make UDP work a better way.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/15639

-- 
Edit this bug report at http://bugs.php.net/?id=15639&edit=1

Reply via email to