problems with fopen

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ura
Forum Newbie
Posts: 2
Joined: Thu Apr 24, 2003 6:29 am

problems with fopen

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

You're trying to open a remote file via http/ftp/... fopen url-wrappers?
ura
Forum Newbie
Posts: 2
Joined: Thu Apr 24, 2003 6:29 am

problems with fopen

Post 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.
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

fsockopen

Post 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;
?>
Post Reply