#15639 [Sus]: detecting end of UDP packets
| From: | pollita@php.net | Date: | Thu, 01 May 2003 22:43:54 +0000 |
| Subject: | #15639 [Sus]: detecting end of UDP packets | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-38901@lists.php.net to get a copy of this message | ||
ID: 15639
Updated by: pollita@php.net
Reported By: rip at undernet dot org
Status: Suspended
Bug Type: *Network Functions
Operating System: All
PHP Version: 4.1.1
New Comment:
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?
Previous Comments:
------------------------------------------------------------------------
[2002-09-26 10:30:01] wez@php.net
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] wez@php.net
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.
------------------------------------------------------------------------
[2002-03-16 12:16:29] wez@php.net
My man page says that recv is identical to recvfrom with
a NULL from parameter, so I don't see how this can fix
it.
I still don't think this is technically possible over UDP.
If you can show me some real working C code where it works,
I will implement it.
------------------------------------------------------------------------
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