fsockopen, fwrite problem

Posted on 2006-03-24
Last Modified: 2012-06-27

this isnt really an fsockopen or fwrite problem as such! i'm using the following code...

function http_spawn($page)
       $basepath=ereg_replace('[^/]*$', '', $_SERVER['PHP_SELF']);
       $cbSock=fsockopen('localhost', $_SERVER['SERVER_PORT'], $errno, $errstr, 5);
       if ($cbSock)
           fwrite($cbSock, "GET {$basepath}{$page} HTTP/1.1\r\n"
               ."Host: {$_SERVER['HTTP_HOST']}\r\n\r\n");

         while (!feof($cbSock))
            echo fgets($cbSock, 128);



to kick off a call to a page. got the code from...


anyway, this works fine on one server i tried it on. a redhat linux server(apache 2 i think). works perfectly. then i tried the same code on a different server and i'm getting 404 errors...

HTTP/1.1 404 Not Found Date: Fri, 24 Mar 2006 12:12:15 GMT Server: Apache/1.3.34 (Unix) PHP/4.4.2 mod_ssl/2.8.25 OpenSSL/0.9.7d FrontPage/ mod_throttle/3.1.2 Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1 11c
Not Found
The requested URL /page.php was not found on this server.


Apache/1.3.34 Server at Port 80

i've tried changing paths, specifying the path to the file, the url to the file. all sorts of things. am at my wits end with this! anyone see any obviuos errors or anything at all???

Question by:Fatlog
    1 Comment
    LVL 6

    Accepted Solution

    Try taking off the very last "\r\n" in the fwrite string.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    A colleague recently asked me about how to give his client a small part of the web site that could be completely under the client's control.  Since I have done this sort of thing before to add emergency banners to a web site, I decided I would creat…
    Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now