Re: URL -> stream context

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

 



On Fri, January 20, 2006 7:10 am, Jochem Maas wrote:
> I think you need to create a stream context resource with:
>
> http://www.php.net/manual/en/function.stream-context-create.php
>
> set the options you need on it with:
> http://www.php.net/manual/en/function.stream-context-set-option.php
>
> then pass the resource as the 4th arg to fopen() (rather passing in an
> array)
>
>
> ...i think

My whole entire point is this:

I have no idea what all the options are that I would need to duplicate
the code that is built-in to http://php.net/fopen

I really don't want to re-invent the wheel of figuring out all those
options when they are already coded in fopen.

The examples of HTTP and FTP are all very nice, but I'd have to code
for SSL and files and all manner of other protocols to come anywhere
close to the functionality of fopen.

Alas, with fopen, there is no control over connection timeout.

Everybody experienced in PHP keeps talking about the new streams stuff
as if it's a Magic Bullet that will make this all better.

It's not.

It adds layer upon layer of complication to application code, and I'm
sure it's wondeful if one wants the fine-grained control over a
zillion things I don't understand, and I don't WANT to understand --
at leat not at the expense it would take to gain an understanding
necessary to use stream-contexts.

What 99% of developers want, however, is to ignore all the gory
details of all the different schemes and protocols, and get their
data.
$file = fopen($any_url_in_any_protocol);

A large proportion of those developers also want to have a site that
does not seem "slow" if it's stuck waiting for some resource.

So they want fopen() to have a developer-configurable timeout.

Does not exist.

The only way you can get developer-configurable timeout is to use
fsockopen or the new stream-context stuff, both of which require a
Ph.D. in eleventeen different scheme/protocol technologies to get the
kind of functionality you get with fopen.

I hope I'm making sense here, and clearly laying out the issue,
because apparently it hasn't gotten through to most readers in
previous messages.

Currently in PHP you have two options:

Use fopen, keep life simple, but have an infinitely slow response when
your application depends on a dodgy remote server over which you have
no control.

Use fsockopen or streams and spend the next 4 years coding your
application to understand all the ins and outs of protocols you really
don't WANT to understand the details of that should be a black box to
your application.

Do you REALLY want to try to figure out what kind of an array you need
to build and what data you have to send/recieve/parse and act upon to
get an HTTPS feed?  With fopen() it's just taken care of.  With
stream-context, you're going to have to actually understand all that
SSL stuff before you can get your data.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
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