From reading the PHP manual, socket_recv and socket_read function looks same to me, both function get data from client.
can any one tell me what are different between those 2 functions?
socket_recv
returns the number of bytes received
socket_read
returns the data that has been received
With socket_recv
you can read bytes from the buffer AND know how many bytes have been recevied. With socket_read
you can only read a specific amount of data from the buffer
From http://www.faqs.org/faqs/unix-faq/socket/#b:
2.18. What is the difference between read() and recv()?
From Andrew Gierth ([email protected]):
read() is equivalent to recv() with a flags parameter of 0. Other
values for the flags parameter change the behaviour of recv().
Similarly, write() is equivalent to send() with flags == 0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With