ID: 15639
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Feedback
Bug Type: *Network Functions
Operating System: All
PHP Version: 4.1.1
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2002-03-16 12:16:29] [EMAIL PROTECTED]
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.
------------------------------------------------------------------------
[2002-02-21 20:07:45] [EMAIL PROTECTED]
In C, recvfrom() takes a length argument, but behaves with UDP like
fread should : "Reading stops when length bytes have been read or EOF
is reached, whichever comes first."
Using recvfrom() with length set to 4096 will get the 20 bytes packets
without blocking anything.
The bug has prolly something to do with the use of recv() versus
recvfrom().
------------------------------------------------------------------------
[2002-02-20 22:42:53] [EMAIL PROTECTED]
I'll look into UDP sockets in PHP in more detail soon.
In the meantime, I'm not sure that what you are suggesting is possible,
since UDP is a connectionless protocol, how can we detect the end of a
packet/stream?
UDP is supposed to be used with known packet sizes.
If you can show me some C code where what you propose works, I'll
integrate it with the new PHP streams code.
--Wez.
------------------------------------------------------------------------
[2002-02-20 07:02:31] [EMAIL PROTECTED]
In fact it's worst than that, setting the socket non-blocking makes
fread not working on unix/win.
------------------------------------------------------------------------
[2002-02-20 06:41:24] [EMAIL PROTECTED]
It will kill Windows compatibility, fixing the functions is way better.
------------------------------------------------------------------------
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