c++ - I don't know how much data the server returns. How does PHP's socket_read() receive the complete data?
淡淡烟草味
淡淡烟草味 2017-05-16 13:09:13
0
1
675

If the data sent by the server always exceeds the maximum number of bytes that the client can bear at one time, how can the client determine that the received data is complete without performing the socket_read operation? How much data does the server return? Composed of /n. I tried using a while loop to read the server's data, but there was a problem with the operation.

淡淡烟草味
淡淡烟草味

reply all(1)
phpcn_u1582

If it is a short link, use socket_set_nonblock to set the socket link to non-blocking, and then execute socket_read in a loop. When the return value length is 0, jump out of the loop and the reception ends (this method may cause problems in some cases).

It is best to specify the data length on the server side so that there will be no errors.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template