Re: non-blocking request to a url (via curl or file_get_contents or whatever)...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



because I like talking to myself :-P ....

Jochem Maas wrote:
> hi,
> 

...

> I definitely give a hoot about the content returned ... all I want is for the request to
> go out on the wire and then have my script immediately continue with what it should be doing.
> 
> I believe this would require creating a non-blocking connection in some way, but I'm stuck
> as to the correct way to tackle this. I've been reading about non-blocking sockets/streams etc
> but I'm just becoming more and more confused really, anyone care to put me out of my misery?

did more reading, still unsure of the whole thing, this is what I have right now:

	    $url = array('', 'tbs.tradedoubler.com', '/report?blablablabla');
            $isSSL = true;
            $proto = $isSSL ? 'ssl://' : 'http://';
            $port  = $isSSL ? 443 : 80;
            $errno = $errstr = null;
            if ($sock = fsockopen($proto.$url[1], $port, $errno, $errstr, 10)) {
                stream_set_blocking($sock, 0);
                fwrite($sock, "GET {$url[2]} HTTP/1.0\r\n");
                fwrite($sock, "Host: {$url[1]}\r\n");
                //fwrite($sock, "Content-length: 0\r\n");
                //fwrite($sock, "Accept: */*\r\n");
                fwrite($sock, "\r\n");
                fclose($sock);
            }

does this make any sense, will this work at all?
would the 10 second timeout [potentially] negate all the hard work?

> 
> rgds,
> Jochem
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux