Page 1 of 1

HTTP sockets

Posted: Thu Jul 09, 2009 11:24 am
by michellylei

Code: Select all

 
<?php
$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
 .......
 
    $out = "GET / HTTP/1.1\r\n";
    $out .= "Host: http://www.example.com\r\n";
    $out .= "Connection: Close\r\n\r\n";
    fwrite($fp, $out);
    while (!feof($fp)) {
        echo fgets($fp, 128);
    }
 
fgets get only one response from peer or fgets will get many msg from example.com? when fwrite call once, example.com only reply one message right??