Page 1 of 1

problems with fopen

Posted: Thu Apr 24, 2003 6:29 am
by ura
Hello to all.
I have a problem with "fopen".
I want to control that the time of duraccion of they fopen is not superior to X seconds.
I am tried It with "set_time_limit" but it does not leave to me.

Something is happened to you. Thanks

Posted: Thu Apr 24, 2003 7:14 am
by volka
You're trying to open a remote file via http/ftp/... fopen url-wrappers?

problems with fopen

Posted: Thu Apr 24, 2003 8:50 am
by ura
I have a function in which I must send a series of different information to url“s.
The problem is that when doing one fopen(http://xxx.xxx.xxx.xxx:80/prueba.php),
if the server takes long time in responding, slows down all the process to me.
What wanted is to give timeout to fopen it .

Thanks.

fsockopen

Posted: Thu Apr 24, 2003 8:55 am
by []InTeR[]
Maybe the function u need is fsockopen and not fopen.

With this function you have to sendout the GET headers yourself.
Some more work, but i think there are lots of examples.

Like from php.net

Code: Select all

<?php
$fp = fsockopen ("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) &#123;
    echo "$errstr ($errno)<br>\n";
&#125; else &#123;
    fputs ($fp, "GET / HTTP/1.0\r\nHost: www.example.com\r\n\r\n");
    while (!feof($fp)) &#123;
        echo fgets ($fp,128);
    &#125;
    fclose ($fp);
&#125;
?>