php-general Digest 28 Dec 2007 15:46:55 -0000 Issue 5204
Topics (messages 266313 through 266321):
socket_read can not read the whole HTTP page?
266313 by: ked
266316 by: Eddie Dunckley
266317 by: Eddie Dunckley
266320 by: ked
Re: fopen() for http:// sometimes working, sometimes not
266314 by: Albert Wiersch
Re: vim/php color scheme
266315 by: Nathan Nobbe
Re: Asynchronous socket connection timing issue.
266318 by: Nicolas Le Gland
266319 by: Nicolas Le Gland
Unix date
266321 by: tedd
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
I wrote those script to get HTTP url content, and it works , but it can't
read the whole content of the page.
Blocked on "while ($out = socket_read($socket, 1024)) ".
browser show the processbar all the time , and the page is not completed
display,
If I press ESC key to cancel the request , the resource of page show that :
the target URL were not read completed .
next codes never been executed .
Why socket_read blocked?
Additional : The network and URL are absolute valid all the time . the size
of target page is about 30k bits .
script :
<?
header("Content-type: text/html; charset=UTF-8");
error_reporting(E_ALL);
echo "<h2>TCP/IP Connection</h2>\n<pre>";
$service_port = 80;
$host = "10.1.1.144";
$file = "/index.aspx";
$address = gethostbyname('10.1.1.144');
/* Create a TCP/IP socket. */
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket < 0)
{
echo "socket_create() failed.\n reason: " . socket_strerror($socket) .
"\n";
} else
{
echo "OK.\n";
}
echo "try connect to '$address' : '$service_port'...";
$result = socket_connect($socket, $address, $service_port);
if ($result < 0)
{
echo "socket_connect() failed.\n reason: ($result) " .
socket_strerror($result) . "\n";
} else {
echo "OK.\n";
}
//$in = "HEAD / HTTP/1.1\r\n";
$in = '';
$in .= "GET {$file} HTTP/1.1\r\n";
$in .= "Accept: text/html\r\n";
$in .= "Accept-Language: zh-cn\r\n";
//$in .= "Accept-Encoding: gzip, deflate\r\n";
$in .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET
CLR 2.0.50727)\r\n";
$in .= "Host: {$host}\r\n";
$in .= "Cache-Control: no-cache\r\n";
$in .= "Connection: Keep-Alive\r\n\r\n";
echo "send HTTP HEAD request...\n{$in}";
socket_write($socket, $in, strlen($in));
echo "OK.\n";
echo "read response:---------------\n\n<textarea>";
$len = 0;
$out= '';
while ($out = socket_read($socket, 1024)) //
-------------------------------wait for too long time .!!!!!!!!!
{
$len += strlen($out);
echo $out;
}
echo "</textarea>";
echo "close socket ...";
socket_close($socket);
echo "OK.\n\n";
?>
--- End Message ---
--- Begin Message ---
On Fri 28 Dec 07, ked wrote:
> I wrote those script to get HTTP url content, and it works , but it
> can't read the whole content of the page.
> Blocked on "while ($out = socket_read($socket, 1024)) ".
> $in .= "GET {$file} HTTP/1.1\r\n";
try to change this to $in .= "GET {$file} HTTP/1.0\r\n";
> $in .= "Connection: Keep-Alive\r\n\r\n";
and change this to
$in .= "Connection: closed\r\n\r\n";
--
Eddie Dunckley - [EMAIL PROTECTED] - Realtime Travel Connections
IBE Development, www.rttc.co.za, cell 083-379-6891, fax 086-617-7831
Where 33deg53'37.23"S 18deg37'57.87"E Cape Town Bellville Oakdale ZA
Chaos, panic, and disorder - my work here is done.
--- End Message ---
--- Begin Message ---
On Fri 28 Dec 07, Eddie Dunckley wrote:
> On Fri 28 Dec 07, ked wrote:
> > I wrote those script to get HTTP url content, and it works , but
> and change this to
> $in .= "Connection: closed\r\n\r\n";
soz that should be close not closed;
--
Eddie - Chaos, panic, and disorder - my work here is done.
--- End Message ---
--- Begin Message ---
Wow, That's correct answer! Thank to Eddie Dunckley !
scheme:
$in .= "GET {$file} HTTP/1.0\r\n"; //-----------
$in .= "Accept: text/html\r\n";
$in .= "Accept-Language: zh-cn\r\n";
$in .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET
CLR 2.0.50727)\r\n";
$in .= "Host: {$host}\r\n";
$in .= "Cache-Control: no-cache\r\n";
$in .= "Connection: closed\r\n\r\n";//------------must be "closed"
1.must be "HTTP/1.0" : why? IE post "HTTP/1.1" .
2. must be "closed" : so that should be close not closed;
Both modification are required.
Shall anyone tell me sth. about "HTTP/1.0" and "HTTP/1.1" ?
best regards!
ked
> -----Original Message-----
> From: Eddie Dunckley [mailto:[EMAIL PROTECTED]
> Sent: Friday, December 28, 2007 3:50 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] socket_read can not read the whole HTTP page?
>
> On Fri 28 Dec 07, ked wrote:
> > I wrote those script to get HTTP url content, and it
> works , but it
> > can't read the whole content of the page.
> > Blocked on "while ($out = socket_read($socket, 1024)) ".
> > $in .= "GET {$file} HTTP/1.1\r\n";
> try to change this to $in .= "GET {$file} HTTP/1.0\r\n";
>
> > $in .= "Connection: Keep-Alive\r\n\r\n";
> and change this to
> $in .= "Connection: closed\r\n\r\n";
>
> --
> Eddie Dunckley - [EMAIL PROTECTED] - Realtime Travel
> Connections IBE Development, www.rttc.co.za, cell
> 083-379-6891, fax 086-617-7831 Where 33deg53'37.23"S
> 18deg37'57.87"E Cape Town Bellville Oakdale ZA
> Chaos, panic, and disorder - my work here is done.
>
> --
> PHP General Mailing List (http://www.php.net/) To
> unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--- End Message ---
--- Begin Message ---
""Albert Wiersch"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Yes, I have SSH access. I will keep that in mind. Upgrading to 5.2.5 may
> have addressed this issue though. If not, then I'll concentrate on a
> possible DNS resolution problem.
Well, it seems to still be happening. This describes the problem but I
haven't found a solution that works for me yet:
http://bugs.php.net/bug.php?id=11058
Is it a PHP problem or DNS? It works sometimes but not other times......
something strange is going on.
Albert
--- End Message ---
--- Begin Message ---
On Dec 27, 2007 2:32 PM, Daniel Brown <[EMAIL PROTECTED]> wrote:
> On Dec 27, 2007 2:27 PM, OOzy Pal <[EMAIL PROTECTED]> wrote:
> > Daniel,
> >
> > Sweet! Mine is version 7.x but I got it. I will check under vim7x. I
> > post if I have further questions.
> >
> > Thank you
>
> You're welcome, but try to keep non-PHP-related questions on their
> respective lists. This one is really only for PHP questions, I just
> thought that particular question and answer would benefit the PHP
> developer community in the archives.
bagh! i have enough trouble copying my .vimrc from box to box let alone
bothering to customize a colorscheme and port that as well. find a
colorscheme
you like, drop it in .vimrc and be done w/ it.
hows that for the developer community archives :)
-nathan
--- End Message ---
--- Begin Message ---
Having succeeded in writing the same code using the BSD sockets extension
without any such delay, I filled a bug concerning stream implementation.
http://bugs.php.net/?id=43695
Feel free to reply there.
--
Nicolas Le Gland
--- End Message ---
--- Begin Message ---
Having succeeded in writing the same code using the BSD sockets extension
without any such delay, I filled a bug concerning stream implementation.
http://bugs.php.net/?id=43695
Feel free to reply there.
--
Nicolas Le Gland
--- End Message ---
--- Begin Message ---
Hi gang:
Using:
$unix_in = 1255845600;
echo(date("M d, Y h:i:s a",$unix_in));
On one sever, produces: Oct 18, 2009 02:00:00 am
But on another sever, produces: Oct 18, 2009 12:00:00 am
This difference appears to be a combination of "time-zone" and
"daylight-savings" considerations. In other words, the function
date() looks at the server's time (whatever that is set for, right or
wrong) and uses that for the calculation.
So, what's the best method in keeping things consistent across
servers? Is there one?
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---