HTTP sockets

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
michellylei
Forum Newbie
Posts: 1
Joined: Thu Jul 09, 2009 10:59 am

HTTP sockets

Post 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??
Last edited by Weirdan on Thu Jul 09, 2009 1:12 pm, edited 1 time in total.
Reason: added [code] tags, removed email address (see forum rules)
Post Reply