Results 1 to 4 of 4

Thread: Opening socket to a file

  1. #1
    Join Date
    Feb 2007
    Location
    🌎
    Posts
    528
    Thanks
    10
    Thanked 10 Times in 10 Posts
    Blog Entries
    2

    Default Opening socket to a file

    Any ideas how to manipulate the following code...
    PHP Code:
    set_time_limit(20);
    ob_start();
    header("Content-Type: text/plain");

    $host "www.google.com";

    $post "HEAD / http/1.1\r\n";
    $post .= "Host: " $host "\r\n";
    $post .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.2) Gecko/20060308 Firefox/1.5.0.2\r\n";
    $post .= "Keep-Alive: 200\r\n";
    $post .= "Connection: keep-alive\r\n\r\n";

    $sock fsockopen($host,80);
    fwrite($sock$poststrlen($post));

    while (!
    feof($sock)){
    echo 
    fgets($sock);
    }
    ob_end_flush(); 
    ....(o_ Penguins
    .---/(o_- techno_racing
    +(---//\-' in
    .+(_)--(_)' The McMurdo 500

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    'Manipulate it'? What exactly do you want it to do?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Feb 2007
    Location
    🌎
    Posts
    528
    Thanks
    10
    Thanked 10 Times in 10 Posts
    Blog Entries
    2

    Default

    ... whoops.

    I thought I typed:

    "... to use a file, rather than a root domain?

    Example:

    http://www.google.com/program.exe

    instead of:

    http://www.google.com"

    Stupid Internet.
    ....(o_ Penguins
    .---/(o_- techno_racing
    +(---//\-' in
    .+(_)--(_)' The McMurdo 500

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    The slash after 'HEAD ' is the path: the section of the URL between the domain and the first #. In your example, you'd change it to '/program.exe'.

    HTTP is defined in RFC2616. It will be worth a read if you're manipulating HTTP data.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •