All pastes #448861 Raw Edit

Someone

public text v1 · immutable
·published 2007-04-19 22:22 UTC
rendered paste body
<?php
 
        $socket=fsockopen("www.php.net",80,$error);
        if(!$socket)
        {
                echo "socket opening error\n";
                exit;
        }
        echo "connection opened\n";
        if(!fputs($socket,"GET / HTTP/1.1\r\nHost:
www.php.net\r\n\r\n"))
        {
                echo "socket writing error\n";
                exit;
        }
        while(!feof($socket))
        {
                $data=fread($socket,1000);
                if(!$data)
                {
                        echo "socket reading error\n";
                        exit;
                }
                echo "read ",strlen($data)," bytes\n";
        }
        echo "reached the end of data\n";
        fclose($socket);
?>