fsockopen timing out due to no new line being added to reply

123 views Asked by At

The string that is returned back from server does not contain a new line. What would be a better method or replace fgets since also the string length is not known until the data is received.

At the moment im using 200 character count but this is truncating the full string. When the # is exceeded we are presented with internal server 500.

$fp = fsockopen("IP Address", 2000, $errno, $errstr, 20);

if (!$fp) {
    echo "$errstr ($errno)<br />\n";
} else {
    fwrite($fp, 'String of Data');

    while (!feof($fp)) {
        echo fgets($fp, 200);
    }
    fclose($fp);
}
0

There are 0 answers