|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-01-18 21:16 UTC] ceo at l-i-e dot com
Description:
------------
I love the simplicity of fopen() that takes most URLs / files / whatever and does what I want.
Do whatever it takes to start sending me the data.
I NEED the ability to set the time-out for the opening, as well as the time-out after the stream has opened.
I'm stuck with duplicating whatever code is down in fopen() in my own PHP code to detect and initiate protocol specific minutia because fopen() has no user-configurable timeout, but fsockopen doesn't do all that.
$parts = parse_url($url);
extract($parts);
switch($scheme){
case 'http': fputs("GET $path HTTP/1.0\n"); fputs("Host: $host\n"); break;
case 'ftp': fputs("GET $path\n"); break;
.
.
.
}
I REALLY don't want to re-invent the wheel here, when I know that code is down in the guts of fopen()
A function stream_set_connection_timeout() to let me tell PHP how long fopen() should wait would make life way more better for many users, I believe.
Expected result:
----------------
The PHP Dev Team is going to add this function because YOU ROCK!
:-)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 09:00:01 2025 UTC |
I think an excellent solution would be to add a "timeout" option to the Socket stream options. The HTTP stream already supports timeout, but not regular sockets. For example, I want to connect to a Redis server using tcp for caching (infinite timeout needed for blocking calls) and may want to connect to a different server for some other purpose with a short timeout. Example: $context = stream_context_create(array('socket' => array('timeout' => 5)));