note 66431 added to function.fsockopen

From: Date: Mon, 22 May 2006 12:45:17 +0000
Subject: note 66431 added to function.fsockopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-111822@lists.php.net to get a copy of this message
If you want to GET/POST some page through the HTTP protocol and if you want to keep-alive your connection, you may have a problem with a loop-stuck. Here is hint how to solve it: <?php $fp = fsockopen ("www.php.net", 80, $errno, $errstr, 30); if(!$fp) { echo $errstr; } else { fwrite($fp, "GET / HTTP/1.1\r\nHost: www.php.net\r\nConnection: Keep-Alive\r\n\r\n"); $data = ''; while(!feof($fp)) { $data .= fread($fp, 4096); if(substr($data, -9)=="\r\n\r\n0\r\n\r\n") { exit; } } } echo $data; ?> ---- Server IP: 212.47.220.13 Probable Submitter: 193.40.133.134 (proxied: 193.40.10.178) ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.fsockopen.php Edit -- http://master.php.net/note/edit/66431 Del: integrated -- http://master.php.net/note/delete/66431/integrated Del: useless -- http://master.php.net/note/delete/66431/useless Del: bad code -- http://master.php.net/note/delete/66431/bad+code Del: spam -- http://master.php.net/note/delete/66431/spam Del: non-english -- http://master.php.net/note/delete/66431/non-english Del: in docs -- http://master.php.net/note/delete/66431/in+docs Del: other reasons-- http://master.php.net/note/delete/66431 Reject -- http://master.php.net/note/reject/66431 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#111822) next »