while (!feof($socket)) { $line = fgets($socket, 4096); $result[] = $line; }