Answer the question
In order to leave comments, you need to log in
How to stop the loop if fread passed all the data?
I receive data of 16 bytes from the socket and write them to a string. How do I know that fread has passed all the data and then stop the while loop?
Tried using feof function but doesn't work
$socket = stream_socket_client($ip . ":" . $port, $errno, $errstr, 10, STREAM_CLIENT_CONNECT);
stream_set_timeout($socket, 10);
$data = "";
while(/* код для остановки */) {
$data .= fread($socket, 16);
}
return $data;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question